You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a similar issue. I am working on MacOsX with python 2.7.13 and Lua 5.2.
I am trying to call python from within lua.
If I try py = require 'python'
I get the error: no field package.preload['python'] no file '/Users/name/dgdinst/lib/python.lua' no file '/Users/name/dgdinst/lib/python.so'
Similarly when I try py = require 'lua-python'
I get the error message: dlopen(/Users/TOM/name/lib/lua-python.so, 2): Symbol not found: _PyCFunction_Type Referenced from: /Users/name/dgdinst/lib/lua-python.so Expected in: flat namespace in /Users/name/dgdinst/lib/lua-python.so
Good question.
No idea. Do you mean the python.lua file that is included in the lunatic-python (v1.0) repository?
This python.lua file is called by > require 'python' and has suitable syntax to load the lua-python.so library.
I have been able to do some more digging, and I believe the issue is caused by differences between RTLD_NOW and RTLD_GLOBAL. See comment Gustavo Niemeyers comment
It's just a matter of replacing the flag RTLD_NOW in the loadlib.c file of the Lua distribution by the or'ed version RTLD_NOW|RTLD_GLOBAL.
However this proofing difficult. If I get lua from homebrew, it comes pre-compiled and I can't modify loadlib.c. If I install lua from source I don't seem to get the correct lua dynanic libraries liblua.5.2.dylib
Has anyone else succeeded with lunatic-python on a mac?
No, python.lua has been removed a long time ago. The lua-python.so binary has been renamed to python.so and lua.so for loading into lua and python vm respectively.
Can you show the output of the CMake build? If building with CMake->gnu make, you can add VERBOSE=1 to the make command to see the full invocation.
The output is:
lua-python.so:
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.51.1)
Next I go to test and get the error /tests$ lua test_py.lua lua: test_py.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/x86_64-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' test_py.lua:1: in main chunk [C]: in ? Press any key to continue...
Well, set LUA_CPATH as I see libs copied to site-packages
export LUA_CPATH="/usr/lib/python2.7/site-packages/?.so;;"
also change 'python' -> 'lua-python' $ lua test_py.lua lua: error loading module 'lua-python' from file '/usr/lib/python2.7/site-packages/lua-python.so': /usr/lib/python2.7/site-packages/lua-python.so: undefined symbol: _Py_ZeroStruct stack traceback: [C]: in ? [C]: in function 'require' test_py.lua:1: in main chunk [C]: in ? Press any key to continue...
Weee new issue:) What does it mean? Is "lua-python.so" the right lib to use in lua scripts? Why it is installed in python2.7/site-packages ?
What should I do to fix?
Activity
greatwolf commentedon May 7, 2017
Where did you put the compiled
python.solua module?ingojahn commentedon May 7, 2017
Good question.
No idea. Do you mean the python.lua file that is included in the lunatic-python (v1.0) repository?
This python.lua file is called by > require 'python' and has suitable syntax to load the lua-python.so library.
I have been able to do some more digging, and I believe the issue is caused by differences between RTLD_NOW and RTLD_GLOBAL. See comment Gustavo Niemeyers comment
However this proofing difficult. If I get lua from homebrew, it comes pre-compiled and I can't modify loadlib.c. If I install lua from source I don't seem to get the correct lua dynanic libraries liblua.5.2.dylib
Has anyone else succeeded with lunatic-python on a mac?
greatwolf commentedon May 7, 2017
No,
python.luahas been removed a long time ago. Thelua-python.sobinary has been renamed topython.soandlua.sofor loading into lua and python vm respectively.Can you show the output of the CMake build? If building with CMake->gnu make, you can add
VERBOSE=1to themakecommand to see the full invocation.ingojahn commentedon May 7, 2017
In that case I am very confused. I have downloaded a copy of the repository zip and it correctly builds the two file lua-python.so and lua.so.
At no stage is it building a python.sp
Here is the code
$ gmake VERBOSE=1
python setup.py build
running build
running build_ext
building 'lua-python' extension
creating build
creating build/temp.macosx-10.12-x86_64-2.7
creating build/temp.macosx-10.12-x86_64-2.7/src
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pythoninlua.c -o build/temp.macosx-10.12-x86_64-2.7/src/pythoninlua.o -I/usr/include/lua5.2
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/luainpython.c -o build/temp.macosx-10.12-x86_64-2.7/src/luainpython.o -I/usr/include/lua5.2
creating build/lib.macosx-10.12-x86_64-2.7
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-2.7/src/pythoninlua.o build/temp.macosx-10.12-x86_64-2.7/src/luainpython.o -L/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -lpython2.7 -o build/lib.macosx-10.12-x86_64-2.7/lua-python.so
building 'lua' extension
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pythoninlua.c -o build/temp.macosx-10.12-x86_64-2.7/src/pythoninlua.o -I/usr/include/lua5.2
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/luainpython.c -o build/temp.macosx-10.12-x86_64-2.7/src/luainpython.o -I/usr/include/lua5.2
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-2.7/src/pythoninlua.o build/temp.macosx-10.12-x86_64-2.7/src/luainpython.o -L/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -lpython2.7 -o build/lib.macosx-10.12-x86_64-2.7/lua.so
$gmake VERBOSE=1 install
python setup.py install
--root=/
--prefix=/usr/local
--install-scripts=/usr/local/bin
running install
running build
running build_ext
running install_lib
copying build/lib.macosx-10.12-x86_64-2.7/lua-python.so -> /usr/local/lib/python2.7/site-packages
copying build/lib.macosx-10.12-x86_64-2.7/lua.so -> /usr/local/lib/python2.7/site-packages
running install_egg_info
Writing /usr/local/lib/python2.7/site-packages/lunatic_python-1.0-py2.7.egg-info
greatwolf commentedon May 8, 2017
Can you run
lddon lua-python.so followed withwhichon the lua and python runtime libraries to get their locations.ingojahn commentedon May 8, 2017
For macosx the command is
otool -L lua-python.soThe output is:
lua-python.so:
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.51.1)
which lua/usr/local/bin/lua
which python/usr/local/bin/python
greatwolf commentedon May 8, 2017
The second error message, it could be related to this maybe http://stackoverflow.com/questions/35006614/what-does-symbol-not-found-expected-in-flat-namespace-actually-mean.
I don't have an Mac OSX to test this on so not sure how much help I can provide.
aisurfer commentedon Jul 19, 2017
Hey! I have the same issue.
Firstly i've got repo copy and ran 'sudo make install' (using Ubuntu 14)
Next ran make
$ make VERBOSE=1 python setup.py build running build running build_ext building 'lua-python' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/src x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/lua5.2 -I/usr/include/python2.7 -c src/pythoninlua.c -o build/temp.linux-x86_64-2.7/src/pythoninlua.o -I/usr/include/lua5.2 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/lua5.2 -I/usr/include/python2.7 -c src/luainpython.c -o build/temp.linux-x86_64-2.7/src/luainpython.o -I/usr/include/lua5.2 creating build/lib.linux-x86_64-2.7 x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/pythoninlua.o build/temp.linux-x86_64-2.7/src/luainpython.o -llua5.2 -o build/lib.linux-x86_64-2.7/lua-python.so building 'lua' extension x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/lua5.2 -I/usr/include/python2.7 -c src/pythoninlua.c -o build/temp.linux-x86_64-2.7/src/pythoninlua.o -I/usr/include/lua5.2 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/lua5.2 -I/usr/include/python2.7 -c src/luainpython.c -o build/temp.linux-x86_64-2.7/src/luainpython.o -I/usr/include/lua5.2 x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/pythoninlua.o build/temp.linux-x86_64-2.7/src/luainpython.o -llua5.2 -o build/lib.linux-x86_64-2.7/lua.so Press any key to continue...Next install
$ sudo make install python setup.py install \ --root=/ \ --prefix=/usr \ --install-scripts=/usr/bin running install running build running build_ext running install_lib copying build/lib.linux-x86_64-2.7/lua-python.so -> /usr/lib/python2.7/site-packages copying build/lib.linux-x86_64-2.7/lua.so -> /usr/lib/python2.7/site-packages running install_egg_info Removing /usr/lib/python2.7/site-packages/lunatic_python-1.0-py2.7.egg-info Writing /usr/lib/python2.7/site-packages/lunatic_python-1.0-py2.7.egg-info Press any key to continue...Next I go to test and get the error
/tests$ lua test_py.lua lua: test_py.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/x86_64-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' test_py.lua:1: in main chunk [C]: in ? Press any key to continue...Well, set LUA_CPATH as I see libs copied to site-packages
export LUA_CPATH="/usr/lib/python2.7/site-packages/?.so;;"
also change 'python' -> 'lua-python'
$ lua test_py.lua lua: error loading module 'lua-python' from file '/usr/lib/python2.7/site-packages/lua-python.so': /usr/lib/python2.7/site-packages/lua-python.so: undefined symbol: _Py_ZeroStruct stack traceback: [C]: in ? [C]: in function 'require' test_py.lua:1: in main chunk [C]: in ? Press any key to continue...Weee new issue:) What does it mean? Is "lua-python.so" the right lib to use in lua scripts? Why it is installed in python2.7/site-packages ?
What should I do to fix?
Thanks in advance!
cross10 commentedon Jan 1, 2020
将编译好的lua-python.so改名成python.so,放到/usr/lib64/lua/5.1/python.so即可
bastibe commentedon Jan 6, 2020
@cross10 could you repeat that in English?
cross10 commentedon Jan 12, 2020
Change the compiled lua-python.so to python.so, and put it in /usr/lib64/lua/5.1/python.so
If u used was centos7.4 ,and lua's version is 5.1