Challenges

Python allows to install only a single version of a library. If you want another version to be tested or used, you have to uninstall the old one. In global python environments it leads to requirements collisions.

Installing multiple versions of python itself can be confusing. Usually it is recommended to avoid using system wide python versions. They are usually well behind the mainstream.

Links:

  1. How to install the latest Python 3.6 with UBuntu 16.04
  2. Pip install throws TypeError
  3. Kenneth Reitz explaining Python Dependency Management during PyCon 2018.

PyEnv Way

PyEnv, similar to rbenv, allows to use multiple Python versions simultenously. Integrates well with virtualenv. It is able to find the installed version of the tool and run it in a proper virtualenv. Really cool stuff.

Go here for full procedure to install modern Python for UBuntu and RHEL.

RHEL 7 Specific

Redhat supports the most recent Python version in its Redhat Software Collection repository (rhscl and optional-rpms repo) and also supports having and using multiple versions of Python. However it is done on Redhat’s specific way using scl command (scl_source). More on the subject can be found on this blog post.

including in dot files

Activating environment in .bashrc or .bash_profile files:

# Add RHSCL Python 3 to my login environment
source scl_source enable rh-python36