Skip to content

numpy.core.multiarray failed to import (matplotlib cannot be found?) #450

@briochemc

Description

@briochemc

I get this error that suggests that matplotlib cannot be found although I am pretty sure it has been there the whole time :) I tried removing PyPlot and PyCall, re-adding them, and building PyCall after setting ENV["PYTHON"] = "" so that PyCall would be looking for the Python in .julia/conda, but without success. The error output (FYI everything ]uped, too):

julia> using PyPlot
[ Info: Recompiling stale cache file /Users/benoitpasquier/.julia/compiled/v1.1/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
ImportError: numpy.core.multiarray failed to import
[ 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.

ImportError: numpy.core.multiarray failed to import
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('numpy.core.multiarray failed to import')
  File "/Users/benoitpasquier/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 205, in <module>
    _check_versions()
  File "/Users/benoitpasquier/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 190, in _check_versions
    from . import ft2font

Stacktrace:
 [1] pyimport(::String) at /Users/benoitpasquier/.julia/packages/PyCall/ttONZ/src/PyCall.jl:544
 [2] pyimport_conda(::String, ::String, ::String) at /Users/benoitpasquier/.julia/packages/PyCall/ttONZ/src/PyCall.jl:708
 [3] pyimport_conda at /Users/benoitpasquier/.julia/packages/PyCall/ttONZ/src/PyCall.jl:701 [inlined]
 [4] __init__() at /Users/benoitpasquier/.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

I have been using PyPlot for a bit now and it was working fine until I probably updated or changed something I shouldn't have (likely when trying to get widgets to work with Interact in Jupyter notebooks), and now I can't get PyPlot to work anymore... I'm very confused... Any help appreciated!

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