# Errors Using PythonCall.jl and PythonPlot.jl with a Python Virtual Environment

**URL:** https://discourse.julialang.org/t/errors-using-pythoncall-jl-and-pythonplot-jl-with-a-python-virtual-environment/124084
**Category:** General Usage
**Tags:** question, plotting, python, pythoncall, pythonplot
**Created:** [December 22, 2024, 4:45am UTC](https://discourse.julialang.org/t/errors-using-pythoncall-jl-and-pythonplot-jl-with-a-python-virtual-environment/124084 "2024-12-22T04:45:23Z")
**Posts on this page:** 1
**Showing post:** 2

<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, 2:05pm UTC](https://discourse.julialang.org/t/errors-using-pythoncall-jl-and-pythonplot-jl-with-a-python-virtual-environment/124084/2 "2024-12-22T14:05:23Z")

</div>

Hi,

the PythonCall.jl equivalent of [the explicit adding of `site-packages`](https://discourse.julialang.org/t/error-with-importing-matplotlib-pyplot-for-use-with-pycall-jl/124062/5) also seems to work here:

```julia
ENV["JULIA_PYTHONCALL_EXE"] = "C:/Research Software/Python/Virtual Environments/venv_1/Scripts/python.exe"
ENV["JULIA_CONDAPKG_BACKEND"] = "Null"
using Pkg
Pkg.add("PythonCall")
using PythonCall
pyimport("site").addsitedir("C:/Research Software/Python/Virtual Environments/venv_1/Lib/site-packages")
# Alternatively, pyimport("sys").path.insert(0, "C:/Research Software/Python/Virtual Environments/venv_1/Lib/site-packages") also seems to work.
# It's probably safest to add to both site and path.
Pkg.add("PythonPlot")
Pkg.add("Plots")

using Plots
pythonplot()

x = [1,2,3,4,5]
y = x

plot(x,y)
```

---

_[View the full topic](https://discourse.julialang.org/t/errors-using-pythoncall-jl-and-pythonplot-jl-with-a-python-virtual-environment/124084)._
