简体   繁体   中英

Using cmake with enthought for python wrapping

I recently started trying to switch to canopy from ipython notebooks, which I switched to from MATLAB. I am working towards getting a matlab-like experience for development and research.

I am doing most of these setups cross-platform, but I am starting on OS X.

I have been attempting to install packages for use in canopy, some of which require compilation such as SimpleITK and VTK6.0. I had these both successfully installed in my regular python2.7 installation, but I'm having some trouble installing them for canopy. Right now, Im working on recompiling SimpleITK/Superbuild with CMAKE to recreate the python wrappers. It asks for your python executable, include dir, and python lib location. I found the python executeable from sys.executable from within canopy, and the include dir with 'mdfind -name Python.h, which turned out to be the default location, I used the default python lib.

These were

executeable: /Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python

Include: /System/Library/Frameworks/Python.framework/Headers

Lib: /usr/lib/libpython2.7.dylib

But I get the following error upon make:

AssertionError: Filename /Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/os.py does not start with any of these prefixes: ['/Users/jmerkow/Library/Enthought/Canopy_64bit/User', '/Library/Python/2.7/site-packages', '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/Extras/lib/python', '/Users/jmerkow/Library/Python/2.7/site-packages', '/Users/jmerkow/.local/lib/python/2.7/site-packages', '/Users/jmerkow/Library/Python/2.7/lib/python/site-packages']
ERROR
-- Installing numpy from  /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy to /numpy
ERROR
/bin/sh: ../Testing/Installation/PythonVirtualenv/bin/python: No such file or directory
make[5]: *** [lib/_SimpleITK.so] Error 127
make[4]: *** [Wrapping/CMakeFiles/SimpleITK_PYTHON.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-build] Error 2
make[1]: *** [CMakeFiles/SimpleITK.dir/all] Error 2
make: *** [all] Error 2

Also, anyother tips to help me get this done are very welcome

EDIT BELOW

So I attempted to compile using:

/System/Library/Frameworks/Python.framework/Versions/Current/bin/python /System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7/ /System/Library/Frameworks/Python.framework/Versions/Current/lib/libpython2.7.dylib

This compiled and created and egg file named

SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg

but I get the following error when I use enpkg

Traceback (most recent call last): File "/Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/enpkg", line 10, in sys.exit(main()) File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/main.py", line 702, in main reqs.append(Req(name + ' ' + version)) File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/resolve.py", line 32, in init raise Exception("Not a valid requirement: %r" % req_string) Exception: Not a valid requirement: 'SimpleITK 0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg'

with easy_install I get this error:

Processing SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg removing '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg' (and everything under it) creating /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg Extracting SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg to /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages SimpleITK 0.7.0.dev88-ge297c is already the active version in easy-install.pth

Installed /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg Processing dependencies for SimpleITK==0.7.0.dev88-ge297c Searching for SimpleITK==0.7.0.dev88-ge297c Reading cant post Reading cant post Reading cant post No local packages or download links found for SimpleITK==0.7.0.dev88-ge297c error: Could not find suitable distribution for Requirement.parse('SimpleITK==0.7.0.dev88-ge297c')

It looked like I installed it, so I tried to import:

import SimpleITK

Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

You have configure SimpleITK to use your system python executable, library and include files. However, you are trying to run with the Canopy distribution. They are not binary compatible and the mismatch caused that type of program termination.

You canopy python executable was correctly found: /Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python

But you need to make the PYTHON_INCLUDE_DIR and PYTHON_LIBRARY consistent. Try the following commands to help you determine the correct path:

find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name Python.h find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name lib python*.dylib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM