问题描述
如果我尝试在 Windows 8.1 上使用 Julia 0.6.0(使用 Plots 或 PyPlot)绘制任何东西,我会收到运行时错误消息:
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:
运行时错误:
程序;C:UserscAppDataLocalJulia-0.6.0injulia.exe R6034 一个应用程序已尝试加载 C 运行时库不正确.请联系应用程序的支持团队了解更多信息信息.
然后朱莉娅离开了.重新安装 julia 和绘图包没有帮助.任何想法如何解决这个问题?
and julia exits. Reinstalling julia and the plotting packages did not help. Any ideas how to fix this?
推荐答案
对我来说,答案是首先确保我安装了 Python 并安装了 matplotlib.无论出于何种原因,我的系统都安装了多个 Python 版本.运行 python.exe 并尝试导入 matplotlib.
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
如果他们都不能成功导入 matplotlib,则安装它随附的版本或从源安装它(有关说明,请参阅 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).
当您找到一个不返回错误的文件时,请确保 Julia 知道它在哪里.最快的方法是直接通过 Julia (ENV["PYTHON"] = "C:\PythonDirectory\python.exe"
, ENV["PYTHON"] = ""
将默认为 PyPlot 安装的 Python 版本).在 Julia 中设置它不会修改 Windows 环境变量,它将是 PyCall 查找的第一个位置.
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 是变量名
- C:PythonDirectorypython.exe 是值
重新启动计算机,以便使用环境变量.
Restart your computer so the environmental variables are used.
打开 Julia 并确保 Python 环境变量被识别.
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"
在 Julia 中重建 PyCall(重建 PyPlot 也应该可以).
Rebuild PyCall in Julia (rebuilding PyPlot should work as well).
Pkg.build("PyCall")
应该可以的.
我的设置如下.
- 2017 年 11 月之前的所有更新的 Windows 10
- Julia 0.6.0 64 位
- Python 2、Anaconda 2、Anaconda 3 和 miniconda(通过 PyPlot 标准安装)均在没有环境变量的情况下安装
几周前我最后一次使用 PyPlot 时它还在工作,但我怀疑 Windows 的重大秋季更新搞砸了一些事情.
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.
这篇关于使用 PyPlot 时的 Julia 运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!