(If this is a repose, I apologize. I tried to post this question previously, but it looked like the post was deleted instead. I rewrote it after waiting a while (unsuccessfully) to see if the original post showed up.)
Hi all. I’m a new user of BTK (and a novice a building/trouble-shooting source code) and I have a question regarding importing BTK under different instances of Python. First, my system information…
— Early 2011 13” MacBook Pro running OS X 10.10.1 Yosemite
— System default python (/usr/bin/python) : Python 2.7.6
— Anaconda Scientific Python Distribution (~/anaconda/bin/python) : Python 2.7.9, SWIG 3.0.2, Numpy 1.9.1
— The anaconda dist. of python is currently set as my default in my .bash_profile
I use the Anaconda python distribution for data analysis as a way of keeping code/packages organized. I’d like to use the BTK in my analyses, but I am having difficulty getting it to work with the Anaconda python dist. I followed the instructions provided on the BTK wiki for building the core code and python wrappers. When I import with my system default python using…
>>> import sys
>>> sys.path.append("Path/To/Folder containing btk.py”)
>>> import btk
… everything works fine. However, when I launch my anaconda instance of python and do the same thing, I get the following error…
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
I did some research on this error, and it seems like it has something to do with a disconnect between the version of python used to create the wrappers and the version you then try and import the package to. I looked through the CMakeCache.txt file and found a number of variables pointing to my system default python, rather than the anaconda distribution, even though the anaconda is set as the default for my profile. I removed the compiled code and rebuilt with CMake, this time manually specifying values for the following variables so they would point to the correct python…
PYTHON_EXECUTABLE
PYTHON_LIBRARY
PYTHON_INCLUDE_DIR
SWIG_DIR
SWIG_EXECUTABLE
SWIG_VERSION
When I reconfigured with the appropriate files and paths for these variables, everything looked good. The CMake configuration looked to be pointing to the correct folder, and the Numpy dependencies were all being pulled from the anaconda distribution. I ran ‘make’ with verbose output and everything seemed to work and link properly. However, when I went to import BTK in the anaconda python dist., I got the same error. Interestingly, it still imports with the system python.
If anyone has information on this issue or can help me get BTK running with anaconda, I would really appreciate it. Thanks a lot.
(P.S. I also tried the Python Binaries and got the same result)