(Easiest) Way to use Python 3.6 and 3.7 on same computer?

I found this to work after searching for a while. Here are the steps I followed to install an older python version alongside my standard one:

  • Download the Python3.6 tgz file from the official website (eg. Python-3.6.6.tgz)
  • Unpack it with tar -xvzf Python-3.6.6.tgz
  • cd Python-3.6.6
  • run ./configure
  • run make altinstall to install it (install vs altinstall explanation here Difference in details between "make install" and "make altinstall")

You'll normally find your new python install under /usr/local/bin. Now you can create a new virtualenv specifying the python version to use with:

  • virtualenv --python=python3.6 env3.6
  • Get into the virtualenv running the command source env3.6/bin/activate.
  • Install tensorflow with the classic pip3 install tensorflow
  • Profit

One of the recommended ways to have multiple python installations with differing libraries installed is to use Virtualenv. This gives you the possibility to have a specific python environment with it's own set of dependencies for each project you work on. This works not only for the dependencies, but also for different versions of python.

On top of that you can use Pipenv to manage the different virtualenvs. In a Pipfile you can describe your required python and it's dependencies which is used by Pipenv to manage a python env specific for your project.