building python 3.9.1 on jetpack 4.5 and the jetson xavier nx

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

Build Python

Download the latest version of Python, build, and install:

  1. Download the latest Python, version 3.9.1, from https://www.python.org/downloads/.
  2. Untar the file (we’ll assume it’s downloaded to the default ~/Downloads):
    tar xvf Downloads/Python-3.9.1.tar.xz
  3. 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
  4. Change directory into the build directory.
  5. From within the build directory execute the configure script:
    ../Python-3.9.1/configure --enable-optimizations
  6. 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.

  7. Install into the alternate location for this version of Python:
    sudo -H make altinstall
  8. Check for the alternate location with which python3.9. It should return /usr/local/bin/python3.9.

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.

  1. In your home directory create a work folder. On my system I named it ‘vpython’. Change directory (cd) into it.
  2. Then create a Python VE:
    python3.9 -m venv 39
  3. 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.

Install PyQt5

I use Python library PyQt5. In order to do that you must install Ubuntu’s Qt5 support libraries as well as the Python module.

  1. Install Ubuntu Qt5 support: sudo apt install qt5-default
  2. Enable Python 3.9 virtual environment: source $HOME/vpython/39/bin/activate
  3. 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.

getting wiringpi to work under ubuntu 20.10 on a raspberry pi 4b w/4gb


Over the years, one of the software tools I came to depend on was gpio from the project WiringPi. There were others to be sure, but I like using WiringPi. I came to take it for granted, so much so, that when its author, Gordon Henderson, decided to deprecate WiringPi and stop supporting it, I was more than a bit shocked. I read Gordon’s reasons for exiting, and I agree with his reasons. I’m not here to hash over those reasons as it’s now been over a year since that happened.

In the mean time I installed Ubuntu 20.10 for the Raspberry Pi 4B on my RPi 4B’s and went about the business of making sure the core set of tools that I use on Raspbian were also available on Ubuntu 20.10. As it turns out, WiringPi is available, but it won’t work.

The reason is that the version available via apt is version 2.50. The version at a minimum should be 2.54 or greater, which was a special release that Gordon provided for the 4B right after he officially stopped supporting WiringPi in general.

So I contacted Gordon, who advised me to look on Github for a copy of his code. I found that, cloned it, and tried to build and install it. It built but failed to link due to a symbol defined multiply times error. That was due to a structure definition in a header file that showed up twice in two object files. I fixed that by turning the explicit structure definition into a typedef. When I tried again, it built and linked and deployed the shared library. After that, gpio ran just fine as shown above.

The link to my fork with the one fix is here: https://github.com/wbeebe/WiringPi

I picked up a branch in the fork. I will probably delete that, as all I care about right now is the mainline code. If I do anything it will be to clean up the warnings I see as the code builds (and there are a fair number now) as well as reducing dependence on the pre-processor. Reducing dependency on the pre-processor means replacing #defines with const constants, allowing the compiler to do its job and treat C/C++ as a strongly typed language.