Julia runtime error when using PyPlot

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

If I try to plot anything with Julia 0.6.0 (using Plots or PyPlot) on Windows 8.1 I get a runtime error message:

Runtime error:

Program; C:\Users\c\AppData\Local\Julia-0.6.0\bin\julia.exe R6034 An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.

and julia exits. Reinstalling julia and the plotting packages did not help. Any ideas how to fix this?

回答1:

For me the answer was to first make sure I had a Python install that had matplotlib installed. My system, for whatever reason, has multiple installs of multiple versions of Python. Run python.exe and try importing matplotlib.

import matplotlib 

If none of them can successfully import matplotlib then install a version that comes with it installed or install it from source (see the matplotlib website for instructions).

When you find one that doesn't return an error make sure Julia knows where it is. The quickest way is directly through Julia (ENV["PYTHON"] = "C:\\PythonDirectory\\python.exe", ENV["PYTHON"] = "" will default to the version of Python installed by PyPlot). Setting it in Julia will not modify the Windows environmental variables and will be the first place PyCall looks.

Alternatively, you can add it to the environment variables, either user or system level environmental variables should do.

  • PYTHON is the variable name
  • C:\PythonDirectory\python.exe is the value

Restart your computer so the environmental variables are used.

Open Julia and make sure the Python environmental variable is recognized.

ENV["PYTHON"] # Should return the directory you set above 

Try setting it yourself if it's still not correct.

ENV["PYTHON"] = "C:\\PythonDirectory\\python.exe" 

Rebuild PyCall in Julia (rebuilding PyPlot should work as well).

Pkg.build("PyCall") 

That should do it.


My setup is as follows.

  • Windows 10 with all updates until the beginning of November 2017
  • Julia 0.6.0 64bit
  • Python 2, Anaconda 2, Anaconda 3, and miniconda (via PyPlot standard install) all installed with no environmental variables

PyPlot was working the last time I used it a few weeks ago but I suspect the big fall update from Windows screwed up something.



回答2:

This answer is thanks to this discussion on github, as well as the comments on the question.

This should not be an issue with Julia itself, rather with the python/anaconda installation on the system or Qt's configuration.

Try the following:

Open a new REPL/session and type:

ENV["MPLBACKEND"]="qt4agg" 

You can also try changing the python environment variable for Julia, then rebuilding the PyCall Julia package:

ENV["PYTHON"]=""; Pkg.build("PyCall") 

On my system (Win 10 Fall Update, ver 1703, build 15063.674), I have to set ENV["MPLBACKEND"]="qt4agg" every time that I start the Julia REPL (you can also add it to the startup file, .juliarc.jl ). Afterwards, using Plots and subsequent calls function properly.



回答3:

This is what I have done. I followed their ideas and it seems that I have not installed "Matplotlib" yet. And then I opened the cmd window and input

python -mpip install -U pip; python -mpip install -U matplotlib 

I am using the newest version: python 3.6; And finally it works.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!