I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.
Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.
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 environment variable (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):
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):
Documentation: Using Python on Windows
PEP 397 - Python launcher for Windows
Data scientist has been called “the sexiest job of the 21st century,” presumably by someone who has never visited a fire station. Nonetheless, 23/09/2020
If you’ve picked up this book, you’re probably aware of the extraordinary progress that deep learning has represented for the field of artificial intelligence in the recent past. In a mere five ye...
A Practical Approach to Computer Algorithms Using Python® and C# Rod Stephens started out as a mathematician, but while studying at MIT, he discovered how much fun algorithms are. He took every al...
Professional-quality code does more than just run without bugs. It’s clean, readable, and easy to maintain. To step up from a capable Python coder to a professional developer, you need to learn indu...