10

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?

khelwood
  • 55,782
  • 14
  • 81
  • 108
tho_mi
  • 698
  • 3
  • 9
  • 16
  • install both and specify which version you need in the script in which you execute tensorflow – Cut7er Sep 02 '18 at 15:13
  • 1
    You might want to have a look [here](https://conda.io/docs/user-guide/tasks/manage-environments.html). You can create two environments and then `source activate env1` and `source deactivate env1` depending on which version you want – Sheldore Sep 02 '18 at 15:16
  • Thanks for your answers, I'll try that! – tho_mi Sep 02 '18 at 15:17
  • What you need is termed "virtual environment" and common choices are `virtualenv` and `anaconda` – Reut Sharabani Sep 02 '18 at 15:22

2 Answers2

8

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.

paweloque
  • 18,466
  • 26
  • 80
  • 136
  • 1
    Thanks, but I managed to find an easier way. I installed Python 3.6.6 in a separate folder and installed spyder there. The shortcut to the corresponding .exe automatically starts with Python 3.6.6, so I just have to switch spyder if I want to use another Python version. While this solution isn't very beautiful, it's enough for my purposes. – tho_mi Sep 02 '18 at 17:27
7

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:

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
Community
  • 1
  • 1
belvederef
  • 2,195
  • 19
  • 16
  • Following the steps to install Python3.6 seems to have overwritten my python 3.7. Not sure why but I explicitly followed these steps! – Preethi Vaidyanathan Mar 22 '20 at 19:34
  • I am not sure why, it could depend on the location of your original installation. In hindsight, however, I would definitely recommend using `conda`, especially if working on multiple python projects. – belvederef Mar 22 '20 at 22:16
  • Agreed- I would suggest conda, or if that isn't possible, using `pyenv` to manage multiple installations of python (at least on a mac) – Preethi Vaidyanathan Mar 23 '20 at 00:22