Skip to content

Installing PyPlot in a robust way

Martin Otter edited this page Jan 7, 2020 · 3 revisions

Installing PyPlot with Pkg.add("PyPlot") often fails. In this case it is recommended to install PyPlot in the following way:

  1. Install a Python 3.x distribution that contains Matplotlib.
    Recommended: Anaconda distribution.
    Advantage: very robust;
    Disadvantage: > 3 GByte memory needed;
    ModiaMath is based on the Python 3.x version of Matplotlib where some keywords are different to the Python 2.x version.
    On Windows 10, either provide a julia_start.bat file with the following content (and add <path-to-julia-installation>\bin to the path environment variable):

    call <path-to-Anaconda3>\Anaconda3\Scripts\activate.bat
    julia
    

    and always start julia by calling julia_start,
    or (my preference), add additionally the following directories to the path environment variable:

    <path-to-Anaconda3>\Anaconda3
    <path-to-Anaconda3>\Anaconda3\Library\mingw-w64\bin
    <path-to-Anaconda3>\Anaconda3\Library\usr\bin
    <path-to-Anaconda3>\Anaconda3\Library\bin
    <path-to-Anaconda3>\Anaconda3\Scripts
    <path-to-Anaconda3>\Anaconda3\bin
    <path-to-Anaconda3>\Anaconda3\condabin
    

    and start julia by calling julia

  2. Include the path to the Python executable in your startup file (Julia 1.0: <path-to-user>/.julia/config/startup.jl):
    ENV["PYTHON"] = joinpath("<path-above-Anaconda3>", "Anaconda3", "python.exe")

  3. Start Julia, give the command ENV["PYTHON"] in the REPL, and check whether the path is correct (if you made a typo in the startup file, Julia might use another Python executable and PyPlot might crash Julia).

  4. If you have used a different Python installation before, execute the command ]build PyCall (or using Pkg; Pkg.build("PyCall"), exit Julia and start Julia again.

  5. Install PyPlot via ]add PyPlot (or using Pkg; Pkg.add("PyPlot"))

Clone this wiki locally