Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows switch between python 2 and 3

1,904 views
Skip to first unread message

Daiyue Weng

unread,
Oct 27, 2016, 11:11:33 AM10/27/16
to
Hi, I installed Python 2.7 and Python 3.5 64 bit versions on Win 10. Under

C:\Python35

C:\Python27

Both have been set in environment variable Path.

When I type python in cmd, it only gives me python 2.7, I am wondering how
to switch between 2 and 3 in command prompt.

cheers

Veek M

unread,
Oct 27, 2016, 11:26:47 AM10/27/16
to
you could try typing the path to the interpreter:
c:\Python35\bin\python.exe foo.py

or changing the path ordering using 'set /?' i think - google

Peter Otten

unread,
Oct 27, 2016, 11:38:45 AM10/27/16
to
Daiyue Weng wrote:

> Hi, I installed Python 2.7 and Python 3.5 64 bit versions on Win 10. Under
>
> C:\Python35
>
> C:\Python27
>
> Both have been set in environment variable Path.
>
> When I type python in cmd, it only gives me python 2.7, I am wondering how
> to switch between 2 and 3 in command prompt.
>
> cheers

https://docs.python.org/3.5/using/windows.html#python-launcher-for-windows

Steve D'Aprano

unread,
Oct 27, 2016, 11:42:58 AM10/27/16
to
I don't use Windows, so I am guessing, but you could try:

python2
python27

python3
python35




--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

Zachary Ware

unread,
Oct 27, 2016, 11:50:12 AM10/27/16
to
On Thu, Oct 27, 2016 at 10:11 AM, Daiyue Weng <daiyu...@gmail.com> wrote:
> Hi, I installed Python 2.7 and Python 3.5 64 bit versions on Win 10. Under
>
> C:\Python35
>
> C:\Python27
>
> Both have been set in environment variable Path.
>
> When I type python in cmd, it only gives me python 2.7, I am wondering how
> to switch between 2 and 3 in command prompt.

Along with Python 3.5, the Python Launcher for Windows (py.exe) was
installed in C:\Windows, unless you unchecked it. You can choose
which interpreter you want to run by an argument to py.exe; for Python
2.7, use `py -2.7`; for Python 3.5, use `py -3.5`. There are also
shortcuts for "latest Python 2" and "latest Python 3", `py -2` and `py
-3` respectively. Calling `py` on its own will default to matching
`py -2`, but settings can be changed in C:\Windows\py.ini. See
https://docs.python.org/using/windows.html#launcher for more details.

--
Zach

Daiyue Weng

unread,
Oct 27, 2016, 12:16:40 PM10/27/16
to
python windows launcher seems like the best option here.

thanks

On 27 October 2016 at 16:49, Zachary Ware <zachary.w...@gmail.com>
wrote:

eryk sun

unread,
Oct 27, 2016, 4:14:54 PM10/27/16
to
On Thu, Oct 27, 2016 at 3:41 PM, Steve D'Aprano
<steve+...@pearwood.info> wrote:
> On Fri, 28 Oct 2016 02:11 am, Daiyue Weng wrote:
>
>> Hi, I installed Python 2.7 and Python 3.5 64 bit versions on Win 10. Under
>>
>> C:\Python35
>>
>> C:\Python27
>>
>> Both have been set in environment variable Path.
>>
>> When I type python in cmd, it only gives me python 2.7, I am wondering how
>> to switch between 2 and 3 in command prompt.
>
> I don't use Windows, so I am guessing, but you could try:
>
> python2
> python27
>
> python3
> python35

These links aren't created by the installer, but you can create them
if that's your preference. Execute the following in an admin command
prompt:

mklink C:\Python27\python2.7.exe C:\Python27\python.exe
mklink C:\Python27\python2.exe C:\Python27\python.exe
mklink C:\Python35\python3.5.exe C:\Python35\python.exe
mklink C:\Python35\python3.exe C:\Python35\python.exe
0 new messages