在Enthought's Canopy与Julia实现PyCall
时存在一些奇怪的问题(我猜这与Canopy没有更新distutils.sysconfig
有关?)。
关于此问题,有一些讨论,通过将PyCall
指向正确的共享库来解决它。
如何使此更改永久(如何更改distutils.sysconfig
)?
一些输出:
julia> using PyPlot
ERROR: could not load module python: dlopen(python.dylib, 9): image not found
in pyinitialize at /Users/bdhammel/.julia/PyCall/src/PyCall.jl:422
in pyimport at /Users/bdhammel/.julia/PyCall/src/PyCall.jl:105
in include at boot.jl:238
in include_from_node1 at loading.jl:114
in reload_path at loading.jl:140
in _require at loading.jl:58
in require at loading.jl:43
at /Users/bdhammel/.julia/PyPlot/src/PyPlot.jl:32
julia> using PyCall
julia> pyinitialize("/Users/bdhammel/Library/Enthought/Canopy_64bit/System/lib/libpython2.7.dylib")
/Users/bdhammel/Library/Enthought/Canopy_64bit/System/lib/libpython2.7.dylib: /Users/bdhammel/Library/Enthought/Canopy_64bit/System/lib/libpython2.7.dylib: cannot execute binary file
julia> using PyPlot
Warning: Possible conflict in library symbol dtrtri_
Warning: Possible conflict in library symbol dgetri_
Warning: Possible conflict in library symbol dgetrf_
julia> plot([1,2])
1-element Array{Any,1}:
PyObject <matplotlib.lines.Line2D object at 0x115b95090>
它绘制了这条线。
我希望能够设置它正常工作,而不必进行pyinitialize
的操作。
来自链接讨论:
PyCall运行python可执行文件并执行:
import distutils.sysconfig
print(distutils.sysconfig.get_config_var('LDLIBRARY'))
print(distutils.sysconfig.get_config_var('PYTHONFRAMEWORKPREFIX'))
这些路径存储在哪里,我应该改变什么?
这些命令在Python中的输出:
In [1]: import distutils
In [2]: print(distutils.sysconfig.get_config_var('LDLIBRARY'))
Python.framework/Versions/2.0.0.dev-f1c6cfc/Python
In [3]: print(distutils.sysconfig.get_config_var('PYTHONFRAMEWORKPREFIX'))
/Library/Frameworks
In [4]: distutils.__file__
Out[4]: '/Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/distutils/__init__.pyc'
最后:我需要担心“无法执行二进制文件”或“可能发生冲突”的部分吗?