Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have Python 3.7 installed on my computer. I want to use tensorflow and just found out that it basically doesn't support 3.7, so I'd like to (also) install Python 3.6.

Any suggestions of how to do that? Do I have to uninstall 3.7 and replace it by 3.6 or is there a way to just use 3.6 for the stuff related to tensorflow?

like image 430
tho_mi Avatar asked Sep 02 '18 15:09

tho_mi


People also ask

Can I have 2 versions of Python installed?

If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.

How do I run multiple versions of Python on Windows?

Install multiple python versions For Windows users, I recommend using the Windows x86-64 executable installer option if you work on a 64bit system. Otherwise, just use the Windows x86 executable installer . After locating the install option for the specific version, just press the download link.

Can I have Python 3.7 and 3.8 at the same time?

You should just install Python 3.7 and Python 3.8 and make sure that the Python Launcher for Windows is also installed (this is the default). Then you could run your scripts using py -3.7 main.py or py -3.8 main.py to run main.py using Python versions 3.7 or 3.8, respectively.


2 Answers

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
like image 81
belvederef Avatar answered Sep 23 '22 01:09

belvederef


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.

like image 21
paweloque Avatar answered Sep 26 '22 01:09

paweloque