# IJulia and Pyplot backend problem with old Python version

**URL:** <https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216>\
**Category:** General Usage\
**Tags:** pyplot, ijulia\
**Created:** [August 3, 2022, 7:29am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216 "2022-08-03T07:29:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 7:29am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/1 "2022-08-03T07:29:47Z")

</div>

Hi all,

I have upgraded my Python to 3.10 just to be able to use Pyplot backend (do not know if it is worth the trouble, perhaps other backend is better)

I want to plot this:

```julia
using Plots; pyplot();

xc = [0,0,1,1]
yc = [0,1,1,0]
zc = [1,1,2,2];

plot(xc,yc,zc,st=:surface,camera=(-30,30))

```

Then error occurs:  
**Warning: You are using Matplotlib 3.3.4, which is no longer**  
**│ officialy supported by the Plots community. To ensure smooth Plots.jl**  
**│ integration update your Matplotlib library to a version \>= 3.4.0**  
\*\*│ \*\*  
**│ If you have used Conda.jl to install PyPlot (default installation),**  
**│ upgrade your matplotlib via Conda.jl and rebuild the PyPlot.**  
\*\*│ \*\*  
**│ If you are not sure, here are the default instructions:**  
\*\*│ \*\*  
**│ In Julia REPL:**  
**│ `**  **│ import Pkg;** **│ Pkg.add("Conda")**  **│ import Conda** **│ Conda.update()** **│ Pkg.build("PyPlot")**  **│ `**  
\*\*│ \*\*  
**└ @ Plots /home/browni/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:29**

I want to change the kernel of Jupyter Notebook to the newest Python 3.10 so I can use pyplot() backend.

This also makes the notebook for Python kernel that used to work with PyplotJS for Python is not working now as well.

Just how to fix this Python kernel ? I have the newest matplotlib now when I check at terminal.

 ![Capture d’écran_2022-08-03_14-23-47](https://global.discourse-cdn.com/julialang/original/3X/2/2/22a78571d9376102a4df23553a0ce7b0c8e59dce.png)

![Capture d’écran_2022-08-03_14-26-24](https://global.discourse-cdn.com/julialang/original/3X/e/0/e0f5480b98c357829d64b36a0d9b35e8f8074b85.png)

![Capture d’écran_2022-08-03_14-27-19](https://global.discourse-cdn.com/julialang/original/3X/c/d/cd5b921680393d433e9298529a6ad612ce5be50e.png)

Different error when I run the code again:

 ![Capture d’écran_2022-08-03_14-32-45](https://global.discourse-cdn.com/julialang/original/3X/d/7/d7ad05768f328f4b2366e0a92f57fb69a547de10.png)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 3, 2022, 9:49am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/2 "2022-08-03T09:49:33Z")

</div>

The Python version used by IJulia is likely a miniconda downloaded automatically when you installed IJulia, not your system Python. You can either re-build IJulia with your system Python or update the matplotlib version used by the Python used by IJulia (as the warning suggests).

If you ask me neither of these is worth the trouble unless you need a specific feature of the PyPlot backend which isn’t supported by GR.

Also the warning is just that, a warning, are you getting actual errors which prevent you from plotting?

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [August 3, 2022, 9:57am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/3 "2022-08-03T09:57:21Z")

</div>

Not an expert, but this [notebook](https://github.com/PaulSoderlind/JuliaTutorial/blob/master/Tutorial_01_Basics.ipynb) has some simple instructions for “Installing Jupyter/JupyterLab - When You Already Have Python Installed” (close to the top of the notebook).

Also, consider checking with  
`using PyPlot;PyPlot.version` and `run(`$(ENV["JUPYTER"]) --version`)`

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 10:41am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/4 "2022-08-03T10:41:44Z")

</div>

It is a warning and unable to show the plot, Pyplot can rotate the plot that is why I need it.

I follow this :

````julia
│ In Julia REPL:
│ ```
│ import Pkg;
│ Pkg.add("Conda")
│ import Conda
│ Conda.update()
│ Pkg.build("PyPlot")

````

I get this:

```julia
Error building `PyCall`: 
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
ERROR: LoadError: Couldn't find libpython; check your PYTHON environment variable.

The python executable we tried was /usr/bin/python3 (= version 3.10).
Re-building with
    ENV["PYCALL_DEBUG_BUILD"] = "yes"
may provide extra information for why it failed.

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] find_libpython(python::SubString{String}; _dlopen::typeof(Base.Libc.Libdl.dlopen))
   @ Main ~/.julia/packages/PyCall/7a7w0/deps/buildutils.jl:72
 [3] find_libpython(python::SubString{String})
   @ Main ~/.julia/packages/PyCall/7a7w0/deps/buildutils.jl:41
 [4] top-level scope
   @ ~/.julia/packages/PyCall/7a7w0/deps/build.jl:82
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [6] top-level scope
   @ none:5
in expression starting at /home/browni/.julia/packages/PyCall/7a7w0/deps/build.jl:43
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
  [2] (::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:962
  [3] withenv(::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String}})
    @ Base ./env.jl:172
  [4] (::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1506
  [5] with_temp_env(fn::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1390
  [6] (::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1469
  [7] mktempdir(fn::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem ./file.jl:750
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem ./file.jl:748
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1435
 [10] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1432
 [11] build_versions(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}; verbose::Bool)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:943
 [12] build(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}, verbose::Bool)
    @ Pkg.Operations ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:822
 [13] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:992
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:149
 [15] build(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:144
 [16] #build#99
    @ ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
 [17] build
    @ ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
 [18] #build#98
    @ ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:141 [inlined]
 [19] build(pkg::String)
    @ Pkg.API ~/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:141
 [20] top-level scope
    @ REPL[4]:1

```

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 10:42am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/5 "2022-08-03T10:42:25Z")

</div>

I am reading it, great tutorial…

I think my problem is very complicated .

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 11:00am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/6 "2022-08-03T11:00:48Z")

</div>

PyCall and GMT failed to precompiled

 ![Capture d’écran_2022-08-03_18-00-12](https://global.discourse-cdn.com/julialang/original/3X/1/c/1c7a987d1232daa90d3ed2edd6b973609acb8e64.png)

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 11:43am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/7 "2022-08-03T11:43:26Z")

</div>

So after a lot of trial and error and help from all of you here.

I realize upgrading Python the main system is useless, sorry Python!!

So here what I do, cd to an empty directory for a new environment then:

```julia
julia --project="."

```

Then at REPL:

```julia
julia> ENV["PYTHON"]="/usr/bin/python3.6"
(to get back to the original python installed at the system)

julia> ]
pkg> add PyCall

julia> using Pkg
julia> Pkg.build("PyCall")

julia> ]
pkg> add PyPlot
julia> Pkg.build("PyPlot")

julia> using IJulia
julia> notebook()

```

Then at the notebook (the python kernel works again to plot, but the matplotlib problem still persists in Julia kernel):

 ![Capture d’écran_2022-08-03_18-42-25](https://global.discourse-cdn.com/julialang/original/3X/9/1/91b4d09531cedabd00d6eebab57d32e3176c67d1.png)  
 ![Capture d’écran_2022-08-03_18-42-38](https://global.discourse-cdn.com/julialang/original/3X/5/9/5991d0c9c3d2602f2b649781676bf88837c22115.png)

The right question is how to install new matplotlib in conda in Julia?  
so I can do pyplot() in IJulia

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 12:26pm UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/8 "2022-08-03T12:26:47Z")

</div>

After a bit trial and error,

I open a notebook with Python kernel, and check turns out if I run pip list it will point to conda inside `.julia`

Then I install matplotlib in a new notebook by :

```julia
pip install matplotlib
pip show matplotlib

```

Go back to Julia kernel notebook to plot an example with pyplot() backend (still the same):

 ![Capture d’écran_2022-08-03_19-24-25](https://global.discourse-cdn.com/julialang/original/3X/d/9/d93556e29acf90ee25ff10f887456d3fe6fb2310.png)

the same as I use terminal for REPL when I call pyplot()  
 ![Capture d’écran_2022-08-03_19-25-23](https://global.discourse-cdn.com/julialang/original/3X/b/3/b3c5d79474829c400dbe36eb69f16c40f38146e1.png)

I will try to find a way on how to install matplotlib in conda in Julia then.

using Conda, does not really work to install matplotlib, it installed python 3.10 but then this error occurs:

**CondaVerificationError: The package for python located at /home/browni/.julia/conda/3/pkgs/python-3.10.5-h582c2e5\_0\_cpython**  
**appears to be corrupted. The path ‘lib/python3.10/unittest/pycache/loader.cpython-310.pyc’**  
**specified in the package manifest cannot be found.**

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 3, 2022, 1:19pm UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/9 "2022-08-03T13:19:23Z")

</div>

[https://github.com/JuliaPy/Conda.jl/issues/222](https://github.com/JuliaPy/Conda.jl/issues/222)

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 4, 2022, 6:45am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/10 "2022-08-04T06:45:25Z")

</div>

I try this:

I have tried this codes in Julia REPL:

```julia
julia> using Conda
julia> Conda.add("matplotlib", :pyplot_env)

```

It created a new conda environment at this location: `/home/browni/.julia/conda/3/envs/pyplot_env`

At the terminal it said:  
To activate this environment, use

```julia
  $ conda activate /home/browni/.julia/conda/3/envs/pyplot_env

```

 ![Capture d’écran_2022-08-04_13-07-37](https://global.discourse-cdn.com/julialang/original/3X/d/d/ddb6c975b14f428ae46b606932d9d795609e8f7f.png)

I activate this conda environment at OS terminal I type:

```julia
source /home/browni/.julia/conda/3/bin/activate 
conda activate pyplot_env

```

It activates pyplot\_env in terminal.

Then, `cd` to the empty directory for clean environment for Julia then type:

```julia
julia --project="."

julia> import Pkg;
julia> Pkg.add("Conda")
julia> import Conda
julia> Conda.update()
julia> Pkg.build("PyPlot")

```

Still cannot make the Pyplot() backend works… Try a lot of ways, but will try again. If anyone able to share their experience in same issue feel free to help me here.

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 4, 2022, 7:21am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/11 "2022-08-04T07:21:29Z")

</div>

**Case closed / Solution obtained:**

I create a new folder `pyplotenv`, and `cd` to there then type this from terminal:

```julia
julia --project="."

import Conda
Conda.update()

add PyPlot

```

Then run the plotting:

```julia
using Plots
pyplot()

xc = [0,0,1,1]
yc = [0,1,1,0]
zc = [1,1,2,2];

plot(xc,yc,zc,st=:surface,camera=(-30,30))

```

in Julia REPL and IJulia

 ![Capture d’écran_2022-08-04_14-18-30](https://global.discourse-cdn.com/julialang/original/3X/c/5/c5063f931d84db36e72a791f915611e57c20bbaa.png)  
 ![Capture d’écran_2022-08-04_14-20-31](https://global.discourse-cdn.com/julialang/original/3X/9/0/90a9d4ce1b948691787fdf9b97277bf812f173e8.png)

Now it works. Hope this can help others who face issue with matplotlib and pyplot backend.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [August 4, 2022, 7:36am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/12 "2022-08-04T07:36:31Z")

</div>

In short, what was the problem? A “dirty” old installation?

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 4, 2022, 8:46am UTC](https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/13 "2022-08-04T08:46:33Z")

</div>

The problem is my environment is looking or using the wrong Python.

Thus, I need to set Python Env to Python in Conda.jl, then set the Conda environment variable so I can use new matplotlib for pyplot() backend:

```julia
julia> ENV["PYTHON"] = "/home/browni/.julia/conda/3/envs/pyplot_env/bin/python3"
julia> ENV["CONDA_JL_HOME"] = "/home/browni/.julia/conda/3/envs/pyplot_env"

```
