These instructions will help you build Python 3.9.1 on the Jetson Xavier NX Development Kit running JetPack 4.5. There are two broad stages to building this version. The first is the installation of support developer libraries to allow all Python modules to successfully build, especially _ssl. If _ssl fails to build then pip will not be able to negotiate connectivity with any Python repo, making installation of modules fail. After the installation stage come the build steps.
Install Build Prerequisites
To build all Python modules the following libraries need to be installed. Simply copy-and-paste the following line:
sudo apt install zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev
Download the latest version of Python, build, and install:
- Download the latest Python, version 3.9.1, from https://www.python.org/downloads/.
- Untar the file (we’ll assume it’s downloaded to the default ~/Downloads):
tar xvf Downloads/Python-3.9.1.tar.xz
- Make a build directory at the same level as the untarred source directory. In my case I named the build directory build-python-3.9.1
- Change directory into the build directory.
- From within the build directory execute the configure script:
- Run make with all active cores:
make -j $(nproc)
On my machine I enabled all six cores of the Jetson Xavier NX. Running with fewer cores will result in a longer build time.
- Install into the alternate location for this version of Python:
sudo -H make altinstall
- Check for the alternate location with
which python3.9. It should return
I created a Python 3.9.1 virtual work environment, something I highly recommend. I do that to keep the stock and newly installed environments distinct from one another. These are the specific steps I used to create that virtual Python environment.
- In your home directory create a work folder. On my system I named it ‘vpython’. Change directory (cd) into it.
- Then create a Python VE:
python3.9 -m venv 39
- While you’re there you might as well update pip. Always count on the pip bundled with any version to be out of date with the official version. Using my environment as an example:
$HOME/vpython/39/bin/python3.9 -m pip install --upgrade pip
Now you’re ready to use the latest Python.
I use Python library PyQt5. In order to do that you must install Ubuntu’s Qt5 support libraries as well as the Python module.
- Install Ubuntu Qt5 support:
sudo apt install qt5-default
- Enable Python 3.9 virtual environment:
- Install Python PyQt5:
pip install PyQt5
You’re pretty much free to use Python 3.9 with PyQt5 at this point.
Note that these directions also apply to installation on the Jetson Nano on the same Jetpack version.