using PyPl-6ren">
gpt4 book ai didi

python - 已知会导致 MacOS 崩溃的警告 : PyPlot is using tkagg backend,

转载 作者:行者123 更新时间:2023-12-01 07:01:01 26 4
gpt4 key购买 nike

有谁知道如何更改 backendPyPlot来自"TkAgg"Qt5Agg在 Julia ?

当我尝试 Using PyPlot 时收到此警告在 Julia :

julia> using PyPlot
[ Info: Recompiling stale cache file /Users/tonyspc/.julia/compiled/v1.2/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
┌ Warning: PyPlot is using tkagg backend, which is known to cause crashes on MacOS (#410); use the MPLBACKEND environment variable to request a different backend.
└ @ PyPlot ~/.julia/packages/PyPlot/4wzW1/src/init.jl:192

我尝试使用此处发布的解决方案:https://github.com/JuliaPy/PyPlot.jl/issues/454

但是失败了:

julia> using PyCall
[ Info: Recompiling stale cache file /Users/tonyspc/.julia/compiled/v1.2/PyCall/GkzkC.ji for PyCall [438e738f-606a-5dbb-bf0a-cddfbfd45ab0]

julia> pyimport_conda("PyQt5", "pyqt")
ERROR: PyError (PyImport_ImportModule

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

PyCall is currently configured to use the Python version at:

/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the PyQt5 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 PyQt5 module, you can use `pyimport_conda("PyQt5", PKG)`,
where PKG is the Anaconda package the contains the module PyQt5,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <type 'exceptions.ImportError'>
ImportError('No module named PyQt5',)

Stacktrace:
[1] pyimport(::String) at /Users/tonyspc/.julia/packages/PyCall/ttONZ/src/PyCall.jl:544
[2] pyimport_conda(::String, ::String, ::String) at /Users/tonyspc/.julia/packages/PyCall/ttONZ/src/PyCall.jl:702
[3] pyimport_conda(::String, ::String) at /Users/tonyspc/.julia/packages/PyCall/ttONZ/src/PyCall.jl:701
[4] top-level scope at REPL[4]:1

但是我已经安装了PyQt5使用brew install pyqt

我不知道为什么我的matplot library位于python2目录不是 python3目录:

julia> pyimport("matplotlib").matplotlib_fname()
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/mpl-data/matplotlibrc"

我有python2我的 Mac 上默认安装了 python3使用Homebrew

MacBook-Pro:~ tonyspc$ which python3
/usr/local/bin/python3
MacBook-Pro:~ tonyspc$ which python
/usr/bin/python

我应该设置 ENV["PYTHON"]"/usr/local/bin/python3"

最佳答案

我遇到了类似的问题,我将其添加到我的 .bashrc 中以便每次运行:

导出 MPLBACKEND=qt5agg

然后在执行]build PyCall PyPlot并重新启动julia之后,它似乎找到了正确的后端来绘图。

我打开的相关问题(以及我得到的答案):https://github.com/JuliaPy/PyPlot.jl/issues/453#issuecomment-527163934

关于python - 已知会导致 MacOS 崩溃的警告 : PyPlot is using tkagg backend,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58627696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com