facebookresearch / StarSpace

Learning embeddings for classification, retrieval and ranking.
MIT License
3.94k stars 531 forks source link

Python Wrapper -- test.py results in -> ImportError: Symbol not found: __PyThreadState_Current, #232

Open khalidberry opened 5 years ago

khalidberry commented 5 years ago

running test.py gives the error below

End of logs ############################# run test ############################# Traceback (most recent call last): File "test.py", line 1, in import starwrap as sw ImportError: dlopen(/Users/khaledberry/dev/dataeng/wordmason/Starspace/python/test/starwrap.so, 2): Symbol not found: __PyThreadState_Current Referenced from: /Users/khaledberry/dev/dataeng/wordmason/Starspace/python/test/starwrap.so Expected in: flat namespace in /Users/khaledberry/dev/dataeng/wordmason/Starspace/python/test/starwrap.so /Users/khaledberry/dev/dataeng/wordmason/Starspace/python

Probably the reason for the above error g++ -pthread -std=gnu++11 -O3 -fPIC -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/starspace.cpp g++ -pthread -std=gnu++11 -O3 -fPIC -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/doc_parser.cpp -o doc_parser.o g++ -pthread -std=gnu++11 -O3 -fPIC -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/doc_data.cpp -o doc_data.o g++ -pthread -std=gnu++11 -O3 -fPIC -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/utils/utils.cpp -o utils.o ar rcs libstarspace.a normalize.o dict.o args.o proj.o parser.o data.o model.o starspace.o doc_parser.o doc_data.o utils.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libstarspace.a(proj.o) has no symbols

khalidberry commented 5 years ago

Configuration: [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=apple-clang compiler.libcxx=libc++ compiler.version=9.1 os=Macos os_build=Macos [options] [build_requires] [env]

freakeinstein commented 5 years ago

Hi @khalidberry Are you able to build Starspace non python version? Can you tell me the OSX version?

khalidberry commented 5 years ago

Hey sorry for the late reply, yes I have been able to build and train using the non python version. Used Training modes 1 and 5.

wenjie-yin commented 5 years ago

I had the same problem. Then I found out that it wasn't using the python that I wanted it to use. What solved my problem was: On line 30 of CMakeLists.txt, specify the location of my PythonLibs, i.e. find_package(PythonLibs ${EXAMPLE_PYTHON_VERSION} EXACT PATHS /Users//miniconda3/envs//lib/libpython3.6m.dylib)

bakebrain commented 5 years ago

If you are using anaconda then modifying CMakeLists.txt and setting PYTHON_LIBRARY and PYTHON_INCLUDE_DIR explicitly works:

set(PYTHON_LIBRARY "/home/user/anaconda3/envs/my_env/lib")
set(PYTHON_INCLUDE_DIR "/home/user/anaconda3/envs/my_env/include/python3.7m")