1

I have to call the sum function,sum.py from the lua program main.lua. But I am getting an error.
The python program:

#sum.py
def sum_from_python(a, b):
    return a + b

The lua program:

#main.lua
py = require 'python'
sum_from_python = py.import "sum".sum_from_python
print( sum_from_python(2,3) )

The error :

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 ?

I have already installed Lupa. But it doesn't seems to work. Which package should I have to install. Thanks in advance.

1 Answer 1

1

From what I can gather Lupa is a Python library which allows you to run LUA code in Python, and not the other way around.

If what you want is a module that runs Python code in LUA (and viceversa), you might be interested in Lunatic Python

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it worked. I am trying to link python program to lua. So is it possible to include import statements in python program?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.