Python 使用PyPlot崩溃Julia

Python 使用PyPlot崩溃Julia,python,matplotlib,julia,jupyter-notebook,Python,Matplotlib,Julia,Jupyter Notebook,我刚刚通过Anaconda重新安装了Julia 0.5.2和Python 3.6.3::Anaconda,Inc.。在jupyter笔记本(带有julia内核)中使用PyPlot时,我得到以下结果: InitError: PyError (:PyImport_ImportModule The Python package matplotlib.pyplot could not be found by pyimport. Usually this means that you did not i

我刚刚通过Anaconda重新安装了
Julia 0.5.2
Python 3.6.3::Anaconda,Inc.
。在jupyter笔记本(带有julia内核)中
使用PyPlot
时,我得到以下结果:

InitError: PyError (:PyImport_ImportModule

The Python package matplotlib.pyplot could not be found by pyimport. Usually this means
that you did not install matplotlib.pyplot in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

/home/riccardo/anaconda3/bin/python

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the matplotlib.pyplot module.

One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia.  As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the matplotlib.pyplot module, you can use `pyimport_conda("matplotlib.pyplot", PKG)`,
where PKG is the Anaconda package the contains the module matplotlib.pyplot,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <class 'ImportError'>
ImportError("/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/riccardo/anaconda3/lib/python3.6/site-packages/matplotlib/../../.././libpng16.so.16)",)
  File "/home/riccardo/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/home/riccardo/anaconda3/lib/python3.6/site-packages/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/riccardo/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py", line 21, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/riccardo/anaconda3/lib/python3.6/site-packages/matplotlib/font_manager.py", line 58, in <module>
    from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir

during initialization of module PyPlot

 in pyerr_check at /home/riccardo/.julia/v0.5/PyCall/src/exception.jl:56 [inlined]
 in pyerr_check at /home/riccardo/.julia/v0.5/PyCall/src/exception.jl:61 [inlined]
 in macro expansion at /home/riccardo/.julia/v0.5/PyCall/src/exception.jl:81 [inlined]
 in pyimport(::String) at /home/riccardo/.julia/v0.5/PyCall/src/PyCall.jl:374
 in __init__() at /home/riccardo/.julia/v0.5/PyPlot/src/init.jl:184
 in _include_from_serialized(::String) at ./loading.jl:150
 in _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:187
 in _require_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:217
 in require(::Symbol) at ./loading.jl:371
 in include_string(::String, ::String) at ./loading.jl:441
InitError:PyError(:PyImport\u ImportModule
pyimport找不到Python包matplotlib.pyplot。通常这意味着
您没有在PyCall使用的Python版本中安装matplotlib.pyplot。
PyCall当前配置为在以下位置使用Python版本:
/home/riccardo/anaconda3/bin/python
你应该使用你通常使用的任何机制(apt-get,pip,conda,
等等)安装包含matplotlib.pyplot模块的Python包。
另一种方法是重新配置PyCall以使用不同的Python
系统上的版本:将ENV[“PYTHON”]设置为PYTHON的路径/名称
要使用的可执行文件,运行Pkg.build(“PyCall”),然后重新启动Julia。
另一种选择是将PyCall配置为使用特定于Julia的Python
通过Conda.jl包分发(该包安装了一条私人蟒蛇
Python发行版),其优点是可以安装软件包
并通过Julia及时更新。正如PyCall文档中所解释的,
设置ENV[“PYTHON”]=”,运行Pkg.build(“PyCall”),然后重新启动Julia,
要安装matplotlib.pyplot模块,可以使用'pyimport_conda(“matplotlib.pyplot”,PKG)`,
其中PKG是Anaconda包,包含模块matplotlib.pyplot,
或者,您也可以直接使用Conda软件包(通过
`使用Conda`后跟`Conda.add`etcetera)。
) 
ImportError(“/lib/x86_64-linux-gnu/libz.so.1:未找到版本'ZLIB_1.2.9'(由/home/riccardo/anaconda3/lib/python3.6/site packages/matplotlib/../../../../../../../../../../libpng16.so.16所需)”,)
文件“/home/riccardo/anaconda3/lib/python3.6/site packages/matplotlib/pyplot.py”,第29行,在
导入matplotlib.colorbar
文件“/home/riccardo/anaconda3/lib/python3.6/site packages/matplotlib/colorbar.py”,第36行,在
将matplotlib.contour导入为等高线
文件“/home/riccardo/anaconda3/lib/python3.6/site packages/matplotlib/contour.py”,第21行,在
将matplotlib.font\u管理器导入为font\u管理器
文件“/home/riccardo/anaconda3/lib/python3.6/site packages/matplotlib/font_manager.py”,第58行,在
从matplotlib导入afm、cbook、ft2font、rcParams、get_cachedir
在模块PyPlot初始化期间
在pyerr_中检查/home/riccardo/.julia/v0.5/PyCall/src/exception.jl:56[内联]
在pyerr_中检查/home/riccardo/.julia/v0.5/PyCall/src/exception.jl:61[内联]
宏扩展中的/home/riccardo/.julia/v0.5/PyCall/src/exception.jl:81[内联]
在pyimport(::String)中,位于/home/riccardo/.julia/v0.5/PyCall/src/PyCall.jl:374
在/home/riccardo/.julia/v0.5/PyPlot/src/init.jl中的
在_include _from _序列化(::字符串)在./loading.jl:150
在_require _from _序列化(::Int64,::Symbol,::String,::Bool)在./loading.jl:187
在_require _search _from _序列化(::Int64,::Symbol,::String,::Bool)中./loading.jl:217
在./loading.jl:371处需要(::符号)
在./loading.jl:441的include_字符串(::字符串,::字符串)中
但是,我使用
anaconda navigator
进行了检查,并且
matplotlib
存在(在带有python内核的jupyter笔记本中,matplotlib import pyplot可以正常工作)


你对如何解决这些问题有什么建议吗?我看到其他人已经指出了这一点,但在这些情况下,这似乎与使用多个环境有关。而在我的情况下,我只有一个。

在我的ubuntu 16.04上
ls-la/lib/x86_64-linux-gnu/libz.so.1
return
/lib/x86_64-linux-gnu/libz.so.1->libz.so.1.2.8
它不满足版本“zlibu 1.2.9”,但
ls-la anaconda3/lib/libz.so.1
return
anaconda3/libz/libz.so.11我建议
在运行julia(或者更改LD_LIBRARY_路径)之前,请尝试激活anaconda的virtualenv。在我的ubuntu16.04上,我有完全相同的输出。在anaconda中激活
root
环境后,我检查了julia和python版本:它们都是正确的。但是,使用Pyplot的
再次失败,错误与以前相同。然后我决定
Pkg.build(“PyPlot”)
,现在
使用PyPlot
似乎可行,只是它使用了错误的python版本
INFO:PyCall使用了/home/riccardo/.julia/v0.5/Conda/deps/usr/bin/python(python 2.7.13)at/home/riccardo/.julia/v0.5/Conda/deps/usr/bin/python,libpython=/home/riccardo/.julia/v0.5/Conda/deps/usr/lib/libpython2.7
;Conda.list()
是否在列表中看到matplotlib?
ldd~/anaconda3/lib/libpng16.so | grep libz
->这必须返回与
/lib/x86\u 64-linux-gnu/libz.so.1不同的内容
ls-la/home/palo/anaconda3/lib/libz。所以*
也可能很有趣
find/-name“libz.so*”2>/dev/null
我很好奇是否有libz.so.1.2.9。在运行julia之前,我还会尝试导出LD_LIBRARY_PATH=/home/riccardo/anaconda3/lib:$LD_LIBRARY_PATH
。将其添加到.bashrc。您可以通过命令->
julia-e'println(“export LD\u LIBRARY\u PATH=/home/riccardo/anaconda3/lib:$(ENV[“LD\u LIBRARY\u PATH”])”>~/.bashrc
。然后,您可以编辑
~/.bashrc
中的最后一行,使其不具有
/home/riccardo/anaconda3/lib
两次。(在此更改之前启动的进程可能会自动重新加载此设置)(为了安全起见,可能会创建~/.bashrc的备份副本!))在我的ubuntu 16.04上
ls-la/lib/x86_64-linux-gnu/libz.so.1
return
/lib/x86_64-linux-gnu/libz.so.1->libz.so.1.2.8
它不满足版本'ZLIB_1.2.9',但
ls-la anaconda3/lib/libz.so.1
return
anaconda3/libz/libz.so.1.2.11
所以我建议尝试激活anaconda的病毒在运行julia(或更改LD_LIBRARY_PATH)之前,我也做了同样的操作