About different python versions installation - python

Is it possible to install 3 different python versions on windows 10 simultaneously? I'm using 2.7 for Udacity course, 3.6 for my college project and now I need to install Python 3.5 for "Tensorflow" package. Is it possible to have? Or is there any way to install tensorflow on python 3.6? Any suggestions will be appreciated.

Yes you can have multiple version of Python installed. They just have to be added in your system PATH.
Pay attention that if you let all executables called "python", the latest in your path will be used. You can check this with the command
python --version
For Tensorflow, you can install it on Python 3.6. In my case I used Anaconda 4.4 with Python 3.6 but you can do it by your own.
NB : For tensorflow, pay attention to install CUDA8.0 and add CUDNN version 5.1 (not the version 6.0)

In general you can use virtualenv. Specifically for working with Tensorflow I'd suggest building an env with Anaconda.

Yes just call it directly.
I use python 2, python 3 and pypy.
Call the binary directly - e.g. c:\python27\python.exe myfile.py
When installing packages you can use this as well e.g.
c:\python27\python.exe -m pip install pillow
Alternatively - or in parallel, you can use the Windows subsystem for Linux.
https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
This is separate from your windows installs.
In the window's bash terminal:
python 2:
sudo apt-get install python
python 3:
sudo apt-get install python3
for python 2 pip:
sudo apt-get install python-pip
or for python 3
sudo apt-get install python3-pip

Everyone prefers different ways of using different Python versions. So what I prefer the most is to define different variables for your different Python versions and add/remove the variables in the System variable PATH to use a different Python Version.
So for example:
If you are using anaconda for Python 3, you may make a variable conda3 and add the following in it:
C:\Anaconda3;C:\Anaconda3\Library\mingw-w64\bin;C:\Anaconda3\Library\usr\bin;C:\Anaconda3\Library\bin;C:\Anaconda3\Scripts;
So of course, the values Change depending on where you have installed python.
In a similiar way you can add Python2 and depending on which Version you want to use, you May add(taking the above example as the basis) %Anaconda3% to your System variable PATH.
Note:
Even if you are adding different python variables in the System variable PATH, the System stops searching another python Version as soon as it finds the first one.
If you are using anaconda for python 3.6, I see no Problem in installing tensorflow for python 3.6 - so you can simply do:
conda install tensorflow
and that should work

Related

How to install Python 3.8 along with Python 3.9 in Arch Linux?

I'm working with tensorflow. Recently Arch replaced Python 3.8 with 3.9 and at the moment there is no tensorflow build for Python 3.9. Downgrading Python version for the whole system for that single reason do not looks like good idea for me. My goal is to create virtual environment with python 3.8.
Is there a way to have both (3.8 and 3.9) versions available in the system? Python page of arch wiki doesn't mention that.
EDIT:
I know, I can use: virtualenv -p python3.8 py38 but I need an interpreter in the system.
Go for package python38 in AUR, if you have an AUR helper like yay just use yay -S python38. Otherwise, just download the PKGBUILD and install manually with makepkg.
You can also update python with pacman -Syu (which is now python3.9). Then the two shall live together, inside /usr/bin/python3.x.
Use virtual environment to manage them if you like, virtualenv --python=/usr/bin/python3.x yourenvname.
Downgrading Python version for the whole system for that single reason do not looks like good idea for me.
This is a good observation. You should not modify the system installation of python. After you install the AUR package that Ahacad mentions. I suggest using virtualenv or the standard venv package to create a virtual environment for your tensorflow projects.

Updating Python3 and Pip3 on Mac

I have two versions of python3 installed on my computer. They are located here:
/usr/local/bin/python3
/usr/bin/python3
I have set my PATH variable to use the first version. Running "which python3" routes to this version: /usr/local/bin/python3 -- this is what I want.
Unfortunately, pip3, and yet another version of Python, are installed in a different location (I think the version that comes pre-installed with mac). When I run "pip3 --version" I get the below:
pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
Shouldn't these match? Is there a way to make sure python3 uses the pip3 version via /usr/local/bin/pip3? Do I just need to change / add it to my path somehow?
Another option is to uninstall everything with homebrew (what I used to originally install python3), and then reinstall. However, apparently, per my co-worker, we need to stay on python3.7. I'm worried if I reinstall python3, it will default to 3.8 or higher.
Please help!
There are a few things that I have found increase the chances of success here:
don't mess with the Mac-installed default Python
don't use homebrew to install Python
use pyenv to install and manage Python versions
Here's a useful write-up on The right and wrong way to set Python 3 as default on a Mac.

Error when installing Tensorflow - Python 3.8

I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow.
I've downloaded Python 3.6 but I don't know how to switch this as my default version of python.
Would it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv?
Also, I using Windows and Powershell.
Tensorflow is only supported until python 3.7 as of now.
You can check it here: https://www.tensorflow.org/install/pip
But there is a way to install it on Python3.8, just run the below command that will do your job:
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
This command work on mac and windows both, I haven't tested on Linux.
You should always use venv because by default every project on your system will use these same directories to store and retrieve site packages (third party libraries). At first glance, this may not seem like a big deal, and it isn’t really, for system packages (packages that are part of the standard Python library), but it does matter for site packages.
Consider the following scenario where you have two projects: ProjectA and ProjectB, both of which have a dependency on the same library, ProjectC. The problem becomes apparent when we start requiring different versions of ProjectC. Maybe ProjectA needs v1.0.0, while ProjectB requires the newer v2.0.0.
You can also take a look at anaconda, it’s the most populasr data sciencie platform and will be easy for you install tensorflow and jupiter notebook in just 2 clicks. Anaconda
Uninstall all your python versions and use the latest anaconda.
$ conda create --name tensorflow python=3.5
This way you create a virtual environment with python 3.5 which is supported by tensorflow.
So now you can install it.
$ activate tensorflow
(tensorflow) $ pip install tensorflow
it would have been nice if you would have the share the error screenshot
though as per i got the case
tensorflow work in both 3.8 and 3.6 just you have to check that you have 64bit version not 32 bit
you can acess both version from thier respective folder no need to install a venv
If you don't want to use Anaconda or virtualenv, then actually multiple Python versions can live side by side. I use Python38 as my default and Python35 for TensorFlow until they release it for Python38. If you wish to use the "non-default" Python, just invoke with the full path of the python.exe (or create a shortcut/batch file for it). Python then will take care of using the correct Python libs for that version.
Worked on Python 3.8.2 (default, Mar 05 2020, 18:58:42) [GCC] on linux
pip3 install --upgrade tf-nightly
Python Versions 3.5 - 3.8 are supported now.
You can verify on this page:
https://www.tensorflow.org/install/pip

Package management for coexisting Python 2 and 3

I have been using Python 2.7 for a while now and installing packages using pip install without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.
I have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Python 3.5.3,
I want to be able to use python 2.7 and python 3, my general question is:
What are the best practices when installing packages for both Python 2 and Python 3 on one machine?
As I mentioned using pip install in Python 2.7 works fine, but what about Python 3? I can:
use pip3 install
use python3 -m pip install
Which one should I use and how does it affect the python 2 version of the module? pip3 is not installed on Fedora 25, which raises a new question: how should I install it? as I understand I can:
use dnf install python3-pip (it is unclear if that actually works when pip for Python 2.7 is installed)
use python3 get-pip.py
Finally, would it be a good idea to create a Python 2 and a Python 3 virtual environment to address this issue?
From what I have read on the internet there does not seem to be a clear consensus on these questions, I hope this thread will clarify.
pip3 install and python3 -m pip install — both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install.
And of course I use virtual environments and virtualenvwrapper quite intensively.

Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)

Categories

Resources