Python 3.8 on Drive PX2: Compilation guide

Hi,

Since Jan 2022, we cannot directly install all packages in Ubuntu 16.04, since it reached End-Of-Life support and unfortunately one of these package is Python 3.8+. My workflow requires Python and after a lot of exploring, compiling is the only way to do it. Here is how you do it for PX2 (No cross-compilation => Done directly on PX2)

  • Install general dependencies
sudo apt-get update && \
sudo apt-get upgrade && \
sudo apt-get install -y make build-essential zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev
  • Install SSL:
sudo apt-get install libssl1.0.0=1.0.2g-1ubuntu4.20 -y && \
sudo apt-get update && \
sudo apt-get install libssl-dev=1.0.2g-1ubuntu4.20 -y
  • Install GCC 7:
sudo apt-get update -y && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update -y && \
sudo apt-get install gcc-7 g++-7 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \
sudo update-alternatives --config gcc
  • Download Python (in my case, I have used 3.8.5) and install it:
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz && \
tar xvf Python-3.8.5.tgz && \
cd Python-3.8.5 && \
./configure --enable-optimizations --with-ensurepip=install && \
make -j 4 && \
sudo make altinstall

These commands were tested and worked as of Mai 2022. Hope it helps !!

Cheers,
Vishal Balaji
Perception Engineer@Schanzer Racing

1 Like

Dear @vishal.balaji,
Thank you for sharing the installation steps.