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