简体   繁体   中英

Python: how to access 3.3 if 3.4 is the default?

Running Windows 7. 2.7, 3.3 and 3.4 installed.

I just installed Python 3.3 for a recent project. In the command prompt, python launches 3.4, and py launches 3.3. I can access 3.3 using the 3.3 version of IDLE, but how can I access it via the command prompt? Is there a shortcut like py that I can use? Do I need to define this on my own like an alias? Or is the best route to somehow change the path to temporarily make 3.3 the default?

Just downloaded virtualenv, maybe that might be part of the solution.

If you want to male a file specifically open with a version you can start the file with #! python3.x the x being the version you want. If you want to be able to right click and edit with that version youll need to do some tweaking in the registry

To make it so you can run the different versions of Python from the command prompt, go into C:\\Python33 and C:\\Python34 and make copies of the python.exe that resides there. Rename the copy to python33.exe and python34.exe , respectively, then you can just run

python33 file.py

or

python34 file.py

from the command prompt, and you'll be assured the correct version will be used. I'd also make a copy of the python.exe in C:\\Python27 and name it python2.exe , just so you can specify that version when needed, if you don't remember the search order of your Python directories in your PATH environment variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM