Upgrading a 3.8.1 Python 2.7 PIP installation to Python 3

This is on CentOS 7, for whatever it’s worth. I’d prefer to keep the OS for the time being, but I’ll have to migrate it sooner or later.

The current install is via PIP on default Python 2.7 – and the latest version available is 3.8.1. So, I’d like to install python3, create a new virtualenv, and restore the backup to that virtualenv. Would this work? Or would it carry over all of the 2.7 dependencies, etc.? I obviously don’t have much experience working with python and virtualenvs.

Can you tell which information is missing here?

You need to understand the basic building blocks and logics:

  • Your code and database is 3.8.1.
  • It does not matter where the code is located.
    => you can easily change the location of the code and continue running with the same database.

I.e. in theory you could replace your virtualenv. Create a new virtualenv like /opt/privacyidea-py3/, point your wsgi script against this one, adapt pi.cfg if necessary and replace mod_wsgi!

However, you need to think about the criticality of your system and necessary and possible downtimes. So you might also consider if it makes more sense to setup a new machine and move the data.

I’ve been using that Upgrade page as a reference for years. The only thing that I think is missing, is that 3.9.x is not available in via PIP with Python 2.7 (privacyIDEA · PyPI and version histories show that 3.9.0 requires Python 3.6+).

There’s deprecation warnings and warnings of nonsupport “after the next version” while running pip install --upgrade privacyidea, but that’s not included in the Docs. So, I don’t know if it’s PIP actively deprecating Python 2.7 (not unreasonable) or some other discrepancy, but maybe just add a warning to the upgrade notes.

At the very least, I’ll have to create a new virtual environment with Python 3 (and all dependencies), so an in-place (in-virtualenv) upgrade probably won’t work. I was just hoping to avoid the FreeRadius installation (et al) as well, though I can’t avoid that for much longer.

Thanks for the tips