Comment install both Python 2.x et Python 3.x dans Windows

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment install both Python 2.x et Python 3.x dans Windows

Message par ForumBot »

How to install both Python 2.x and Python 3.x in Windows




Source : Stack Overflow [windows]

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment install both Python 2.x et Python 3.x dans Windows

Message par ayi »

I found that the formal way to do this is as follows:


Just install two (or more, using their installers) versions of Python on Windows 7 (for me work with 3.3 and 2.7).


Follow the instuctions below, changing the parameters for your needs.


Create the following variable d’environnement (to default on double click):


Name:  PY_PYTHON
Value: 3


To launch a script in a particular interpreter, add the following shebang (beginning of script):


#! python2


To execute a script using a specific interpreter, use the following prompt command:


> py -2 MyScript.py


To launch a specific interpreter:


> py -2


To launch the default interpreter (defined by the PY_PYTHON variable):


> py


Resources


Documentation: Using Python on Windows


PEP 397 - Python launcher for Windows

Répondre

Revenir à « Performance & Dépannage »