facebookresearch / StarSpace

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

Python wrapper import results in "undefined symbol: _Py_ZeroStruct" #225

Open maxblumental opened 5 years ago

maxblumental commented 5 years ago

On Ubuntu 16.04 I built starwrap.so and put it in python/test. Then:

    $ cd test
    $ python test.py
    Traceback (most recent call last):
    File "test.py", line 1, in <module>
       import starwrap as sw
    ImportError: /home/blumental/Desktop/StarSpace/python/test/starwrap.so: undefined symbol: _Py_ZeroStruct

Did anyone face the problem?

Update: it works in python 2.7, but fails with python3 (I tried 3.6.5 and 3.7.2).

freakeinstein commented 5 years ago

@maxblumental Could you please check with which python library version you are building pybind against? One way to check is to add a line message(${PYTHON_INCLUDE_DIR}) just below include_directories(${PYTHON_INCLUDE_DIR}) inside the file CMakeLists.txt. Keep an eye for the result. It should print something like, /usr/include/python3.*.

Note: I was unable to reproduce the issue, import starwrap as sw worked with python3 on Ubuntu 16.04 & 18.04. Please provide more details if the issue persists.