I seem to be able to reproduce your second issue. Here is what I did (posted so that PyCall devs can debug)
shell> julia --project=. # to launch julia with a dedicated environment file Project.toml in the current folder
julia> ENV["PYTHON"] = "" # to ensure PyCall installs a separate Python binary instead of using your system one, so that it can manage it without messing up your system
pkg> add PyCall # to make PyCall available in this environment
pkg> build PyCall # to rebuild PyCall in case it has been already build with the system Python binary
julia> exit() # to quit julia
shell> julia --project=. # restart julia so that you can use the newly built PyCall
julia> using PyCall
julia> pyimport_conda("matplotlib", "matplotlib") # to import (and if necessary download) matplotlib
That last command fails with conda reporting it can not resolve. Conda.add
fails the same way. Directly invoking ~/.julia/conda/.../bin/conda install matplotlib
fails in the same way. My system’s conda
does not seem to fail.
pyimport("numpy")
works fine; pyimport_conda("qutip", "qutip")
works fine; so it seems there is some problem specific to matplotlib
and Conda.jl
Even using PyPlot
fails the same way.
The stacktrace is below:
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: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
ResolvePackageNotFound:
ERROR: InitError: failed process: Process(setenv(/home/stefan/.julia/conda/3/x86_64/bin/conda install -y matplotlib
,[“PATH=/home/stefan/.juliaup/bin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl”, “DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus”, “XDG_SESSION_DESKTOP=gnome”, “XDG_SESSION_TYPE=wayland”, “SYSTEMD_EXEC_PID=1792”, “OPENBLAS_DEFAULT_NUM_THREADS=1”, “LC_TIME=en_GB.UTF-8”, “USER=stefan”, “LC_MEASUREMENT=en_GB.UTF-8”, “USERNAME=stefan” … “GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/7e4e215d_e19a_4c28_9620_90184f48ea81”, “GNOME_TERMINAL_SERVICE=:1.871”, “XDG_SESSION_CLASS=user”, “PWD=/tmp”, “DISPLAY=:0”, “GNOME_SETUP_DISPLAY=:1”, “MAIL=/var/spool/mail/stefan”, “CONDA_PREFIX=/home/stefan/.julia/conda/3/x86_64”, “OPENBLAS_MAIN_FREE=1”, “GNOME_KEYRING_CONTROL=/run/user/1000/keyring”]), ProcessExited(1)) [1]
Stacktrace:
[1] pipeline_error
@ ./process.jl:565 [inlined]
[2] run(::Cmd; wait::Bool)
@ Base ./process.jl:480
[3] run
@ ./process.jl:477 [inlined]
[4] runconda(args::Cmd, env::String)
@ Conda ~/.julia/packages/Conda/xMClC/src/Conda.jl:128
[5] add(pkg::String, env::String; channel::String, satisfied_skip_solve::Bool, args::Cmd)
@ Conda ~/.julia/packages/Conda/xMClC/src/Conda.jl:229
[6] add (repeats 2 times)
@ ~/.julia/packages/Conda/xMClC/src/Conda.jl:222 [inlined]
[7] pyimport_conda
@ ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:721
[8] pyimport_conda
@ ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:715 [inlined]
[9] init()
@ PyPlot ~/.julia/packages/PyPlot/H01LC/src/init.jl:173
[10] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1115
[11] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
@ Base ./loading.jl:1061
[12] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
@ Base ./loading.jl:1506
[13] _require(pkg::Base.PkgId, env::String)
@ Base ./loading.jl:1783
[14] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1660
[15] macro expansion
@ ./loading.jl:1648 [inlined]
[16] macro expansion
@ ./lock.jl:267 [inlined]
[17] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1611
during initialization of module PyPlot
caused by: PyError (PyImport_ImportModule
The Python package matplotlib could not be imported 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 that 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 ‘ModuleNotFoundError’>
ModuleNotFoundError(“No module named ‘matplotlib’”)
Stacktrace:
[1] pyimport(name::String)
@ PyCall ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:558
[2] pyimport_conda
@ ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:716
[3] pyimport_conda
@ ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:715 [inlined]
[4] init()
@ PyPlot ~/.julia/packages/PyPlot/H01LC/src/init.jl:173
[5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1115
[6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
@ Base ./loading.jl:1061
[7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
@ Base ./loading.jl:1506
[8] _require(pkg::Base.PkgId, env::String)
@ Base ./loading.jl:1783
[9] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1660
[10] macro expansion
@ ./loading.jl:1648 [inlined]
[11] macro expansion
@ ./lock.jl:267 [inlined]
[12] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1611
@stevengj , pinging you as you seem to be most active PyCall / PyPlot maintainer. Any idea what is happening?
My versioninfo is:
julia> versioninfo()
Julia Version 1.9.1
Commit 147bdf428cd (2023-06-07 08:27 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
Threads: 32 on 32 virtual cores