How to install a newer version of Python 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’.
Here are the steps to install Pandas which has Numpy as a prerequisite.

First, update your repo and then install some dependencies and required libraries.

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

wget -O ~/python3.9.7.tgz https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz

Untar it.

tar -zxvf python3.9.7.tgz

cd into the directory so we can configure and make it. Note the make process will take around 20 minutes.

cd Python-3.9.7/
./configure
sudo make -j4 altinstall

Note that altinstall is critical - you must not overwrite the version of Python that is on the EPIC/RIO.
BTW, the -j4 uses all 4 cores on an EPIC, if you are doing this on RIO, drop the -j4 from the command.

Now install pandas- note this will take about 2 hours to get all the wheel packages, also this will install numpy 1.21.2 which is newer than the version in the Opto repo (1.7.0).

Also note you must explicitly use the pip3.9 installer, not the default EPIC pip installer.

sudo pip3.9 install pandas

Please note that this whole process will take around 3 hours and will sometimes look like nothing is happening.
Just be patient and wait for each step to finish.
@torchard and I have tested it end to end successfully many times.

Lastly, note that from here on out, you will need to call out ‘python3.9’ for any commands as well.

If you have read this far you probably know it goes with out saying, all this is like any other fun-and-games with shell, we don’t support it and if you do a firmware update, you will need to redo all these steps plus any other changes you have made in shell.

2 Likes