Import BTK in Anaconda Python Distribution

322 views
Skip to first unread message

slbarton

unread,
Feb 26, 2015, 4:49:50 PM2/26/15
to btk-...@googlegroups.com
(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)

fabien leboeuf

unread,
Feb 26, 2015, 5:46:28 PM2/26/15
to btk-...@googlegroups.com
hi

It's weird.
i use anaconda with btk and i have no problem.
the better way is to use the btk python binaries; just type :"import btk" in your script.

regards
 


 

--
You received this message because you are subscribed to the Google Groups "BTK Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to btk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Fabien 

Fabien Leboeuf
------------------------------------------------------------------------------------------------
- Ingénieur de recherche au CHU de Nantes                              
- Docteur en mécanique-Biomécanique de l'Université de Poitiers
------------------------------------------------------------------------------------------------
Pôle Médecine Physique et Réadaptation
Hôpital St Jacques
85 rue saint Jacques
44 093 Nantes cedex1
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Tél : 02 40 84 60 88    *
Port: 06 07 79 02 44   *
------------------------------------------------------------------------------------------------

Keyan

unread,
Mar 9, 2015, 7:44:05 AM3/9/15
to btk-...@googlegroups.com
I have the same problem and the same error message with Mac OS X 10.10.2 and a freshly installed Anaconda installation.

Eric Walker

unread,
Mar 16, 2015, 8:34:34 AM3/16/15
to btk-...@googlegroups.com
Hi, 

I recently switched over to the Anaconda distribution from Enthought Canopy, but haven't had a chance to compile btk for Anaconda yet.  I also use a Mac, and was able to get btk compiled and running on Canopy.  You do have to edit the PYTHON and SWIG entries in CMAKE, since CMAKE will find the system installed python and numpy before any distributions.  The one issue that I did have was getting the compiled code to link with the distribution, I think it has to do with the CMAKE install and linker.  Are you moving the compiled btk.so and btk.py files into your working directory before attempting import btk?  

Keyan

unread,
Mar 19, 2015, 11:25:54 AM3/19/15
to btk-...@googlegroups.com
Hi,

I installed btk with the easy_install -N and then tried to import btk. that didn't work.

After reading your email, it tried to copy the .so and the __init__.py (renamed it to btk.py) into my working directory, but that also didnt work.

I'm not really sure that I fully understood what your suggestion was, when you mentioned copying btk to my working directory. Could you be a bit more specific?

Thanks,
Keyan

Keyan

unread,
Mar 19, 2015, 12:18:36 PM3/19/15
to btk-...@googlegroups.com
I have no downloaded the source code and compiled it myself. I have then copied the btk.py and the _btk.so to my working directory.

At first, cmake used my anaconda python but linked against the system's libpython. I redirected it to anaconda's libpython, but that also did not solve the problem.

I'm thankful for any help!

Keyan

On Monday, 16 March 2015 13:34:34 UTC+1, Eric Walker wrote:

Morten Enemark Lund

unread,
May 22, 2015, 6:28:18 AM5/22/15
to btk-...@googlegroups.com
Hi 

I just stumbled on your post. 

I long ago wrapped the b-tk version from the homepage in a conda package. It is hosted on binstar. 

So if you use anaconda just do: 

conda install -c melund btk 

That is all

/Morten


On Thursday, 26 February 2015 22:49:50 UTC+1, slbarton wrote:

Keyan

unread,
May 22, 2015, 1:16:15 PM5/22/15
to btk-...@googlegroups.com
Unfortunately, there is no package for mac os x.

Error: No packages found in current osx-64 channels matching: btk

Cheers,
Keyan

Morten Enemark Lund

unread,
May 23, 2015, 8:12:05 AM5/23/15
to btk-...@googlegroups.com

Yes. Sorry about that. I didn't notice it was for a Mac.  However it was very easy to wrap the pre-compiled package from the homepage. So someone should be able to do the same for Mac. But I have no experience there....


--
You received this message because you are subscribed to a topic in the Google Groups "BTK Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/btk-users/KwxALQ3NpnI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to btk-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages