

Install test module at User level # install User level module as test Python3 -c "import string_utils print(string_utils.is_string('hello'))" # verify it is installed into older python 'dist-packages' Install test module at System level # install System level module as test

Using the default older Python version, let’s first install some small test modules at the System and User level that can serve as markers of our success later. usr/bin/python3.9 -version Install System and User level modules for testing migration # install Python 3.9 (3.8 will still remain) # verify that 3.9 is available for install This does not wipe out or remove the older version, they will both exist in parallel. Note that ‘dist-packages’ is a Debian/Ubuntu convention.įor this article, let’s assume that we started with Python 3.8 (/usr/bin/python3.8) installed as the default on Ubuntu 22.04, and then we installed a newer Python version 3.9 as well (/usr/bin/python3.9). This article will show you how to capture the module name and version used by the older Python version, and use that to install matching modules to the newer version’s dist-packages/site-packages directory. But there is still the matter of Python modules installed at the System level (dist-packages) as well as User level (site-packages) that can be affected by a Python upgrade.

Hopefully you are using venv at the individual project level, which will avoid most problems since a specific Python version and set of modules is explicit. But you most likely have pip modules installed at a version specific ‘dist-packages’ or ‘site-packages’ directory, and those modules have to be freshly installed into the newer version if you want the same behavior. Migrating from one Python 3.x version to a newer 3.x minor version seems like it would just be a simple ‘apt install’ of the latest Python package.
