Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming python.exe to python3.exe for co-existence with python2 on Windows

I would like to install both python 2.7 and python 3.5 on my Windows 10 PC. Both python executables use the same name python.exe.

Is it a good idea to change python.exe to python3.exe as a quick fix for co-existence? Are there any side-effects or other things that I need to be aware?

like image 418
guagay_wk Avatar asked Oct 05 '16 01:10

guagay_wk


People also ask

Can Python 2 and 3 coexist Windows?

We can have both Python 2 and Python 3 installed on any Windows or Linux device. We can either create different environments on different IDEs to use the versions separately or use the following ways to run them using the command prompt.

Can we 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.


Video Answer


2 Answers

You don't need to rename anything for co-existence of different versions of Python.

The different versions of python are installed on different folders automatically.

When use the command prompt you can use the commands py2 or py3 to refer to the different versions of python. The next works too:

C:\Users\user1>py -2

and

C:\Users\user1>py -3

This also works with pip2 and pip3 for install new packages.

For more details, you can read this article: Python Launcher for Windows.

like image 72
Adolfo Correa Avatar answered Nov 02 '22 23:11

Adolfo Correa


You'll need to run python3 instead of python if that's not obvious. This is definitely, as you described, a "quick fix"

My suggested fix is to use virtualenv and pass in the Python executable you would like to use as so:

virtualenv -p /usr/bin/python3.5 /my/virtualenv/>

like image 34
Dan Hoerst Avatar answered Nov 03 '22 00:11

Dan Hoerst