microsoft / ELL

Embedded Learning Library
https://microsoft.github.io/ELL
Other
2.29k stars 294 forks source link

Fatal Python error occurred when I call wrap.py #130

Closed YanMinge closed 6 years ago

YanMinge commented 6 years ago

My development environment is: MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports) macOS High Sierra 10.13.2

I followed the instructions https://github.com/Microsoft/ELL/blob/master/INSTALL-Mac.md complete the construction of the environment, No error message for make and make _ELL_python

but when I follow this instruction to do the sample application https://github.com/Microsoft/ELL/blob/master/docs/tutorials/Getting-started-with-image-classification-on-the-Raspberry-Pi/index.md The following error has appeared:

(py36) yanmingedeMacBook-Pro:1_RPI_Test yanminge$ python ~/project/ELL/tools/wrap/wrap.py model.ell -lang python -target host
Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

and my python environment is

(py36) yanmingedeMacBook-Pro:1_RPI_Test yanminge$ python --version
Python 3.6.4 :: Anaconda, Inc.
(py36) yanmingedeMacBook-Pro:1_RPI_Test yanminge$ which python
/Users/yanminge/miniconda3/envs/py36/bin/python
(py36) yanmingedeMacBook-Pro:1_RPI_Test yanminge$ 

Can anyone help me?

lisaong commented 6 years ago

Hi, as you may have found online, this error happens on Macs when various versions of python conflict.

As this is a setup problem with the Mac environment, here are some references that may help:

https://github.com/snap-stanford/snap/issues/88

...which points to this more detailed troubleshooting guide for something else, but may help you here:

https://docs.google.com/document/d/1ODvtQsJgiTOJH4-qBqwa6eAvoNJoiALqnk2pxFf1IzY/edit

YanMinge commented 6 years ago

I also searched for the same content on google,Because I used to refer to this document to create my environment https://github.com/Microsoft/ELL/blob/master/INSTALL-Mac.md,So I am using a virtual environment,and you can see my python environment returned the expected result.

with otool I got the info

(py36) yanmingedeMacBook-Pro:wrap yanminge$ sudo otool -L ~/project/ELL/build/interfaces/python/_ell_py.so 
/Users/yanminge/project/ELL/build/interfaces/python/_ell_py.so:
    @rpath/libpython3.6m.dylib (compatibility version 3.6.0, current version 3.6.0)
    /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
    /usr/local/opt/libffi/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
    /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)

and libpython3.6m.dylib is just the version I installed on the virtual machine.

Why you haven‘t encountered such a problem?

HaRo87 commented 6 years ago

Hey folks, I am facing the same issue on my Mac. The solutions found via Google did not really help. Any progress on this topic? I tried to use both versions which came with my miniconda installation:

I was using the following command: ~/miniconda3/bin/python3.6 ~/ELL/tools/wrap/wrap.py model.ell -lang python -target host

and still get the following error:

Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

Is there any information about which version of python was used by the ELL project?

Thanks and Cheers, Robert

YanMinge commented 6 years ago

I still didn‘t solve this problem, so I switched it to my ubuntu computer.

HaRo87 commented 6 years ago

Hey @YanMinge, I've switched to Ubuntu 16.04 and did a fresh install following all the steps in the tutorial and I was able to call wrap.py without the error mentioned above. But still no luck, now I am getting a WrapException.

lisaong commented 6 years ago

On macOS Sierra, I managed to get around the PyThreadState_Get: no current thread error by using Homebrew's version of python3 (and libs) instead of Anaconda's. Somehow, the Anaconda libs and Homebrew's libs are incompatible (as hinted by this thread: https://code.activestate.com/lists/python-list/1807/)

  1. brew install python3
  2. If you had anaconda installed, edit .bash_profile to "demote" Anaconda's python: sudo nano ~/.bash_profile
    # added by Anaconda3 5.0.1 installer
    # export PATH="/anaconda3/bin:$PATH"
    export PATH="$PATH:/anaconda3/bin"
  3. Re-run cmake and check that PythonInterp and PythonLibs point to Homebrew's python3:
    -- PYTHONINTERP_FOUND=TRUE
    -- PYTHON_EXECUTABLE=/usr/local/bin/python3.6
    -- PYTHON_VERSION_STRING=3.6.4
    -- PYTHON_VERSION_MAJOR=3
    -- PYTHONLIBS_FOUND=TRUE
    -- PYTHON_LIBRARIES=/usr/local/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib
    -- PYTHON_INCLUDE_PATH=/usr/local/Frameworks/Python.framework/Versions/3.6/include/python3.6m
    -- PYTHON_INCLUDE_DIRS=/usr/local/Frameworks/Python.framework/Versions/3.6/include/python3.6m
    -- PYTHON_DEBUG_LIBRARIES=
    -- PYTHONLIBS_VERSION_STRING=3.6.4
  4. make and make _ELL_python
  5. When running tools like wrap.py, call python3 instead of python (the latter defaults to python2.7).

This workaround doesn't use virtualenvs, which means stuff like NumPy will need to be installed via pip3 install numpy, instead of conda install numpy. It's not as contained as a virtualenv, but at least things should run.

lovettchris commented 6 years ago

closing due to inactivity