I want to upgrade the version of python, numpy, matplotlib, and scipy that I am using on a Ubuntu 22.04 desktop, to mirror the versions that I have on my laptop.
Running apt list --installed reveals that the following packages (amongst many other python ones) were installed via apt-get when the desktop was set up for me:
python3-matplotlib-inline/jammy,jammy,now 0.1.3-1 all [installed]
python3-matplotlib/jammy,now 3.5.1-2build1 amd64 [installed]
python3-numpy/jammy-updates,jammy-security,now 1:1.21.5-1ubuntu22.04.1 amd64 [installed,automatic]
python3-scipy/jammy,now 1.8.0-1exp2ubuntu1 amd64 [installed,automatic]
python3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
python3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
so in particular the last two show that I am running python 3.10.12.
In order to upgrade to python 3.11 I ran
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt install python3.11-full
This gave me bare python, but I'm now having trouble upgrading my libraries, which I would like to manage through pip. In particular I get
$ pip install numpy --upgrade
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in ./.local/lib/python3.10/site-packages (1.26.4)
and similar when I try to upgrade matplotlib - because those packages are already installed, pip doesn't want to touch them.
Is there a way I can install the new packages on my system and "point" my installation of python 3.11 at them? Ideally I would like to have it system wide and not use virtual environments (mainly because I don't understand them, and I just want to be able to call my scripts from anywhere).
As a bare minimum I would like to know how to upgrade to matplotlib 3.8.2 and import it when running a python 3.10 kernel instead of the current mpl 3.5.1, but ideally upgrade everything.
Check which python you use, probably bundled with system one. Create virtual environment for with installed python 3.11 (python -m venv directory_name), activate it and use pip from venv. From my experience this is the easiest way to use desired python version on ubuntu.