Skip to content

Failure to import matplotlib #456

@qua4tre

Description

@qua4tre

This recently began to happen after I uninstalled an old Anaconda distribution and installed Anaconda3 (although I don't know if that's related or not). AFAICT, PyCall is using a private Miniconda installation, not the Anaconda distribution I just installed. However, even when I set ENV["PYTHON"] = "C:/Users/musikat/AppData/Local/Continuum/anaconda3/python.exe" and ]build PyCall, I get the same ImportError after using PyPlot; the only thing that changes is the intervening message about matplotlib not being found by pyimport. Any help would be appreciated.

I am using Julia 1.1.1 on Windows 10.

julia> using PyPlot
[ Info: Installing matplotlib via the Conda matplotlib package...
[ Info: Running `conda install -y matplotlib` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

ERROR: InitError: PyError (PyImport_ImportModule

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

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the matplotlib module, you can
use `pyimport_conda("matplotlib", PKG)`, where PKG is the Anaconda
package the contains the module matplotlib, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ImportError'>
ImportError('DLL load failed: The specified module could not be found.',)
  File "C:\Users\musikat\.julia\conda\3\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
    from . import cbook, rcsetup
  File "C:\Users\musikat\.julia\conda\3\lib\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
    import numpy as np
  File "C:\Users\musikat\.julia\conda\3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\musikat\.julia\conda\3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit

Stacktrace:
 [1] pyimport(::String) at C:\Users\musikat\.julia\packages\PyCall\ttONZ\src\PyCall.jl:544
 [2] pyimport_conda(::String, ::String, ::String) at C:\Users\musikat\.julia\packages\PyCall\ttONZ\src\PyCall.jl:708
 [3] pyimport_conda at C:\Users\musikat\.julia\packages\PyCall\ttONZ\src\PyCall.jl:701 [inlined]
 [4] __init__() at C:\Users\musikat\.julia\packages\PyPlot\cdCMF\src\init.jl:169
 [5] _include_from_serialized(::String, ::Array{Any,1}) at .\loading.jl:633
 [6] _require_from_serialized(::String) at .\loading.jl:684
 [7] _require(::Base.PkgId) at .\loading.jl:967
 [8] require(::Base.PkgId) at .\loading.jl:858
 [9] require(::Module, ::Symbol) at .\loading.jl:853
during initialization of module PyPlot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions