用户在使用 Canopy 时,需要在其中安装 SimpleITK 和 VTK6.0 等依赖包,这些依赖包需要通过编译的方式进行安装。用户按照提示,提供了 Python 执行路径、包含目录和 lib 路径,但是在编译时遇到了错误:
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/.local/lib/python/2.7/site-packages', '/Users/jmerkow/Library/Python/2.7/lib/python/site-packages']
2、解决方案
为了解决这个问题,用户尝试了以下解决方案:
- 使用系统默认的 Python 信息进行编译,并生成了一个名为 SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg 的 egg 文件。
- 将 egg 文件放置在 Canopy 的 site-packages 目录下,并使用 enpkg 和 easy_install 进行安装。
但是,在使用 enpkg 和 easy_install 安装 egg 文件时,又遇到了新的错误:
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'
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')
此外,在导入 SimpleITK 模块时,又遇到了新的错误:
import SimpleITK
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
最终,用户通过以下方式解决了问题:
- 使用 canopy 命令行工具来安装依赖包,而不是使用 enpkg 和 easy_install。
- 在安装依赖包之前,先激活 Canopy 的虚拟环境。
采用这些方法后,用户成功地在 Canopy 中安装了 SimpleITK 和 VTK6.0 等依赖包。