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

**URL:** <https://discourse.julialang.org/t/error-with-importing-matplotlib-pyplot-for-use-with-pycall-jl/124062>\
**Category:** General Usage\
**Tags:** question, plotting, pycall, python\
**Created:** [December 21, 2024, 2:06pm UTC](https://discourse.julialang.org/t/error-with-importing-matplotlib-pyplot-for-use-with-pycall-jl/124062 "2024-12-21T14:06:42Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [December 22, 2024, 1:29pm UTC](https://discourse.julialang.org/t/error-with-importing-matplotlib-pyplot-for-use-with-pycall-jl/124062/5 "2024-12-22T13:29:46Z")

</div>

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`:

```julia
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")

```

---

_[View the full topic](https://discourse.julialang.org/t/error-with-importing-matplotlib-pyplot-for-use-with-pycall-jl/124062)._
