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?
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.
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.
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.
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/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With