Building and installing Python 3.8 on Raspberry PI 5

Hi!

I am trying to build and install Python 3.8.
My RPI 5 came with Python 3.11.2, but my project requires 3.8.

I downloaded the source for 3.8.20 and built it using the instructions in the download.
The build appeared to have been successful…though it did break my ‘ufw’ (I had to copy some packages from dist-packages).

When I installed it, it was installed in /usr/local/bin, whereas 3.11 was installed in /usr/bin.
I changed 3.8 to be default by replacing the symbolic link from 3.11.2 to 3.8.20, so now:
python3 -V
=> results in 3.8.20
pip3 -V
=> results in pip 23.0.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
However, python -V
=> Python 3.11.2
pip -V
=> results in pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)

In any case, I had a number of issues when trying to run python scripts and installing packages.
I had a number of issues trying to install software-properties-common and add-apt-repository ppa:deadsnakes/ppa…could not get anywhere, so attempted to reinstall python 3.8…
That apparently fixed the issue.

But now I cannot install python3.8-venv…
I just get:
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package python3.8-venv
E: Couldn’t find any package by glob ‘python3.8-venv’
E: Couldn’t find any package by regex ‘python3.8-venv’

Any idea what’s going on?

Did you first update the local cache of the package index?

This is not a good idea. Any system components that depend on python expect python3 to be 3.11, not 3.8. Replacing the system Python with another version may break any number of things.

PPAs are an Ubuntu thing. Is your Raspberry Pi running Ubuntu? If it’s running Raspbian, PPAs are unlikely to work.

I don’t understand why you would need to install it if you already successfully built Python 3.8. venv should already be present in the version you built.

1 Like

Have you considered porting your code to 3.11?
This is often far easier than maintaining your own build of old python versions.
People here can help with any tricky porting.