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.