How do i install python 2 and 3 on windows?
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? Show I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
alex 5,8899 gold badges48 silver badges99 bronze badges asked Dec 4, 2008 at 16:18
4 The official solution for coexistence seems to be the Python Launcher for Windows, PEP 397 which was included in Python
3.3.0. Installing the release dumps In order to use the new launcher (without manually setting up your own associations to it), leave the "Register Extensions" option enabled. I'm not quite sure why, but on my machine it left Py 2.7 as the "default" (of the launcher). Running scripts by calling them directly from the command line will route them
through the launcher and parse the shebang (if it exists). You can also explicitly call the launcher and use switches: All manner of shebangs seem to work
as well as wanton abuses
answered Nov 8, 2012 at 21:11
Nick TNick T 24.6k11 gold badges77 silver badges118 bronze badges 8 Here's my setup:
Now in command line you can use
answered Aug 25, 2015 at 5:15
6 From version 3.3 Python introduced Launcher for Windows utility https://docs.python.org/3/using/windows.html#python-launcher-for-windows. So to be able to use multiple versions of Python:
answered Jun 29, 2016 at 8:18
3 You can have both installed. You should write this in front of your script:
or, eventually...
UpdateMy solution works perfectly with Unix, after a quick search on Google, here is the Windows solution:
Same thing: in front of your script.
AtilioA 3711 gold badge5 silver badges17 bronze badges answered Dec 4, 2008 at 16:29
6 Here is a neat and clean way to install Python2 & Python3 on windows. https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a My case: I had to install Apache cassandra. I already had Python3 installed in my D: drive. With loads of development work under process i didn't wanted to mess my Python3 installation. And, i needed Python2 only for Apache cassandra. So i took following steps:
So, my Python3 installation remained intact.
answered Oct 8, 2019 at 11:49
ManjeetManjeet 85715 silver badges23 bronze badges I'm using 2.5, 2.6, and 3.0 from the shell with one line batch scripts of the form:
Name them However, this doesn't help or even affect the Windows file association situation. For that you'll need a launcher program that reads the
answered Jan 12, 2009 at 18:26 1 When you add both to environment variables there will a be a conflict because the two executable have the same name: Just rename one of them. In my case I renamed it to So when I run answered Oct 19, 2017 at 8:24
Charif DZCharif DZ 14.2k3 gold badges16 silver badges39 bronze badges 3 Here you go... winpylaunch.py
I've just knocked this up on reading this thread (because it's what I was needing too). I have Pythons 2.6.1 and 3.0.1 on both Ubuntu and Windows. If it doesn't work for you post fixes here. answered Apr 18, 2009 at 1:45 1 Try using Anaconda. Using the concept of Anaconda environments, let’s say you need Python 3 to learn programming, but you don’t want to wipe out your Python 2.7 environment by updating Python. You can create and activate a new environment named "snakes" (or whatever you want), and install the latest version of Python 3 as follows:
Its simpler than it sounds, take a look at the intro page here: Getting Started with Anaconda And then to handle your specific problem of having version 2.x and 3.x running side by side, see:
answered May 16, 2017 at 19:23
Cale SweeneyCale Sweeney 9641 gold badge14 silver badges34 bronze badges 0 As far as I know Python runs off of the commandline using the PATH variable as opposed to a registry setting. So if you point to the correct version on your PATH you will use that. Remember to restart your command prompt to use the new PATH settings. answered Dec 4, 2008 at 16:29
James McMahonJames McMahon 47.4k64 gold badges205 silver badges278 bronze badges 2 The Python installation normally associates If you want to manually change this association, you can edit these keys in the Windows registry:
Python LauncherPeople have been working on a Python launcher for Windows: a lightweight program associated with answered Mar 3, 2009 at 0:57
Craig McQueenCraig McQueen 40.2k28 gold badges120 silver badges178 bronze badges Here is how to run Python 2 and 3 on the same machine
The Python Launcher for Windows was embedded into Python since Version 3.3, as promised in 2011 when the Stand alone first made its debut: Python Launcher for Windows
answered Jan 3, 2016 at 3:10
1 Easy-peasy ,after installing both the python versions add the paths to the environment variables ;see . Then go to python 2 and python 3 folders and rename them to python2 and python3 respectively as shown and . Now in cmd type python2 or python3 to use your required version see .answered Jun 20, 2019 at 3:11
I think there is an option to setup the windows file association for .py files in the installer. Uncheck it and you should be fine. If not, you can easily re-associate .py files with the previous version. The simplest way is to right click on a .py file, select "open with" / "choose program". On the dialog that appears, select or browse to the version of python you want to use by default, and check the "always use this program to open this kind of file" checkbox. answered Dec 4, 2008 at 16:33
BrianBrian 114k28 gold badges107 silver badges111 bronze badges 1 You should make sure that the PATH environment variable doesn't contain both python.exe files ( add the one you're currently using to run scripts on a day to day basis ) , or do as Kniht suggested with the batch files . Aside from that , I don't see why not . P.S : I have 2.6 installed as my "primary" python and 3.0 as my "play" python . The 2.6 is included in the PATH . Everything works fine . answered Jan 17, 2009 at 16:53
GeoGeo 90.9k115 gold badges335 silver badges513 bronze badges Before I courageously installed both simultaneously, I had so many questions. If I give python will it go to py3 when i want py2? pip/virtualenv will happen under py2/3? It seems to be very simple now. Just blindly install both of them. Make sure you get the right type(x64/x32). While/after installing make sure you add to the path to your environment variables.
Replace the x in the command above to set the path. Then go to both the folders. Navigate to
and rename pip to pip3. If pip3 already exists delete the pip. This will make sure that just pip will run under python2. You can verify by:
In case you want to use pip with python3 then just use
You can similarly do the same to python file and others. Cheers! answered Mar 12, 2017 at 9:32
I had the same problem where I wanted to use python3 for most work but IDA pro required python2. SO, here's what I did. I first created 3 variables in the user environment variable as follows:
Now I added
to PATH variable. So, basically saying that whatever this "PYTHON_ACTIVE" contains is the active python. We programmatically change the contains of "PYTHON_ACTIVE" to switch python version. Here is the example script:
This script takes python version as input and accordingly copies HOME_PYTHON27 or HOME_PYTHON38 to PYTHON_ACTIVE. Thus changing the global Python version. answered May 17, 2020 at 9:25
Mandar SadyeMandar Sadye 6872 gold badges9 silver badges28 bronze badges I would assume so, I have Python 2.4, 2.5 and 2.6 installed side-by-side on the same computer. answered Dec 4, 2008 at 17:31 1 I am just starting out with python now. I'm reading Zed Shaw's book "Learn Python the Hard Way" which requires python version 2.x but am also taking a class that requires python 3.x So here is what I did.
"[ENVIRONMENT]::SETENVIRONMENTVARIABLE("PATH", "$ENV:PATH;C:\PYTHON27", "USER")" (no outside quotes)
NOW for python 3.x Simple, python 3.x download comes with python for windows app. SO simply pin the Python for Windows app to your task bar, or create shortcut to the desktop and you are done! Open Python for Windows for 3.x Open Powershell for python 2.x I hope this helps! answered Feb 7, 2017 at 0:46
Hmm..I did this right now by just downloading Python 3.6.5 for Windows at https://www.python.org/downloads/release/python-365/ and made sure that the launcher would be installed. Then, I followed the instructions for
using python 2 and python 3. Restart the command prompt and then use answered Jun 7, 2018 at 1:37
FearlessFutureFearlessFuture 2,1103 gold badges18 silver badges25 bronze badges Can you have Python 2 and 3 at the same time 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.
How do I install Python 2 on Windows?Installing Python 2.7.. Download the latest Python 2 (64-bit) installer from Python downloads for Windows, usually named Windows x86-64 MSI installer. ... . Install Python 2: ... . Check Python was installed correctly, by opening a command prompt and typing python. ... . Exit the Python interpreter by entering Ctrl+Z.. Does pip install for both Python 2 and 3?In this article, learn how to install pip on Ubuntu 18.04. Note: If you are using Python in a virtual environment created with pyvenv or virtualenv, then pip is available regardless of the version of Python in use. This also applies to Python 2.7. 9 or newer (Python series 2) and Python 3.4 or later (Python series 3).
Can you mix Python 2 and 3?Don't "mix". When the various packages and modules are available in Python 3, use the 2to3 conversion to create Python 3. You'll find some small problems. Fix your Python 2 so that your package works in Python 2 and also works after the conversion.
|