1
我必须调用lua程序main.lua中的sum函数sum.py。但我得到一个错误。
Python程序:从Lua程序中调用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 ?
我已经安装了卢帕。但它似乎并不奏效。我必须安装哪个软件包。提前致谢。
**感谢它的工作有兴趣。我正试图将python程序链接到lua。那么是否有可能在python程序中包含import语句?** – Neenu