Python error: PyThreadState_Get: no current thread after compiling an extension
Question: I am testing [TensorBox](https://github.com/Russell91/TensorBox), which is
based on Google's Tensorflow for some task. There is a small piece of code
that needs to be compiled and I compile it. When running `otool -L
stitch_wrapper.so` this is the output:

    
    
    stitch_wrapper.so (compatibility version 0.0.0, current version 0.0.0)
    libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
    

Whenever I do in python `import stitch_wrapper`, I get the error:

    
    
    Fatal Python error: PyThreadState_Get: no current thread
    Abort trap: 6
    

I read in a comment in [this other
question](http://stackoverflow.com/questions/15678153/homebrew-python-on-mac-
os-x-10-8-fatal-python-error-pythreadstate-get-no-cu) that this happens
whenever a module tries to use a python library that is different than the one
the interpreter uses, that is, when you mix two different pythons. I have two
different pythons in the machine, and the one I am using when running the code
is the `anaconda` python that I installed in my `home` directory. Pardon my
question if I am confused, but how can I compile properly for my `anaconda`
python? I tried importing within my other python and it works well. But I need
it working for my anaconda python.


Answer: As you say, this happens because you have compiled the extension for a
different Python version.

To make it work within Anaconda, you must see if they provide Python
libraries, header files and so on. Then you must recompile everything using
the right flags. If Anaconda provides `python-config`, you can get the flags
from there.

