How to upgrade the version of Python running on EPIC or RIO

We have had a few customers want to do ‘more’ with Python on EPIC and RIO.
The problem they quickly come across is that the version on each is a little dated for their needs.
They specifically need to install either Pandas or a newer version of Numpy.

The solution is to install a newer version of Python alongside the existing version. Note that you can’t just update the version already on the EPIC - it must remain the same as it is used by many other packages on the EPIC/RIO and updating it will break those packages. (Hint, you will need a paperclip to recover).

The key is the ‘altinstall’.

Please Note: As new versions of Linux packages are release, the dependencies of those packages change, this can cause build processes to break. (Which is out side of Opto’s control).

On top of that when we release new groov firmware versions, we make changes to our package repo. This is in our control and we generally only add packages that we know work Ok with our Yocto build of Linux.

Bottom line of those two variables is sometimes the packages don’t align any more and so something that worked months ago, no longer works.

Ok, so that’s the why, how do we install pandas and numpy with a newer version of Python?

Here are the first steps to install Pandas which has Numpy as a prerequisite.
Install the Python prerequisites…

sudo apt-get update
sudo apt-get install libz-dev
sudo apt-get install libffi-dev
sudo apt-get install openssl-dev
sudo apt-get install libreadline-dev
sudo apt-get install libpcap-dev

Get a newer version of python.
NOTE! This may not be the newest version, but it is newer than the one installed from the factory, and it is one we have tested and found to work. You are welcome to try/test newer versions, but if it fails, the best thing to do is a firmware update which will erase all changes made in shell and start over again from fresh.

wget -O ~/python3.9.15.tgz

Untar it.

tar -zxvf python3.9.15.tgz

cd into the directory so we can configure and make it. Note the make process will take around 20 minutes.
Note the use of the altinstall command!

cd Python-3.9.15/
sudo make -j4 altinstall

(Drop the -j4 when on a RIO)

NOTE! If you just want a newer version of Python, you can stop here. You are done.

This next step is very important! You must call out specific versions of numpy and pandas to build the packages.

sudo pip3.9 install numpy==1.23.0 pandas==1.4.4

After the build (which takes a few hours due to all the packages that are built) you can check your built and installed versions:

pip3.9 list

The result of this command on my groov is as follows:

Package         Version
--------------- -------
numpy           1.21.2
pandas          1.3.5
pip             21.2.3
python-dateutil 2.8.2
pytz            2021.3
setuptools      57.4.0
six             1.16.

@torchard and I will try and keep these instructions updated as time goes by.