我必须从lua程序main.lua调用sum函数sum.py.但是我收到了一个错误 python程序:
#sum.py
def sum_from_python(a, b):
return a + b
lua程序:
#main.lua
py = require 'python'
sum_from_python = py.import "sum".sum_from_python
print( sum_from_python(2,3) )
错误:
lua: main.lua:1: module 'python' not found:
no field package.preload['python']
no file '/usr/local/share/lua/5.2/python.lua'
no file '/usr/local/share/lua/5.2/python/init.lua'
no file '/usr/local/lib/lua/5.2/python.lua'
no file '/usr/local/lib/lua/5.2/python/init.lua'
no file '/usr/share/lua/5.2/python.lua'
no file '/usr/share/lua/5.2/python/init.lua'
no file './python.lua'
no file '/usr/local/lib/lua/5.2/python.so'
no file '/usr/lib/i386-linux-gnu/lua/5.2/python.so'
no file '/usr/lib/lua/5.2/python.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './python.so'
stack traceback:
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in ?
我已经安装了Lupa。但它似乎不起作用。我应该安装哪个软件包。提前谢谢。
答案 0 :(得分:1)
从我可以收集的内容中,Lupa是一个Python库,它允许您在Python中运行LUA代码,而不是相反。
如果你想要的是一个在LUA中运行Python代码的模块(反之亦然),你可能会对Lunatic Python感兴趣