Error with importing matplotlib.pyplot for use with PyCall.jl

Seeing as PyCall.jl hasn’t been updated in some time, it’s unlikely to be a very recent development, though I would assume venvs would have worked at some point.

What does seem to work for me is to just add the venv’s site-packages:

ENV[“PYTHON”]="C:/Research Software/Python/Virtual Environments/venv_1/Scripts/python.exe"
using Pkg
Pkg.add("PyCall")
Pkg.build("PyCall")
using PyCall
site = pyimport("site")
site.addsitedir("C:/Research Software/Python/Virtual Environments/venv_1/Lib/site-packages")
plt = pyimport("matplotlib.pyplot")