Sssssuppp
Sssssuppp

Reputation: 711

How do I set default Python in Windows

I have searched many answers on StackOverflow, but I don't seem to find exactly what I want. I have just installed Python 3.7 and when I run the command C:\Users\Dell>python I get this:

Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

I know it has something to do with Anaconda. But, I don't know exactly what's wrong.

Question

I expected to see something like Python 3.7.0. Can someone please tell me where am I going wrong and how should I change this to what I want? What I should do to get Python 3.7 by default?

Upvotes: 1

Views: 16088

Answers (2)

ShadowRanger
ShadowRanger

Reputation: 155363

The answer is: Don't run python. Run py, the Python launcher for Windows. By default, it runs the latest installed version of Python. If you want a specific version, you can follow it with a switch, e.g. py -2 for latest Python 2, py -3.6 for 3.6, etc.

Yes, you could go mucking about with your PATH environment variable settings to try putting the Python 3.7 install folder ahead of 3.6, but then you just have the same problem again a few months from now when you install 3.8. The launcher was created precisely because of the difficulty of managing side-by-side Python installations on Windows, and solves all of these problems seamlessly (plus, it's four fewer characters to type if all you want is the latest installed version!).

Note that for consistency, you basically never want to launch other utilities by name, instead using the py launcher and the -m switch to make sure you're launching the tool associated with the version you expect. So for example, instead of running pip ...args..., run py -mpip ...args..., which ensures you run the pip corresponding to the Python launcher's default Python version.

Upvotes: 6

Kaiwen Chen
Kaiwen Chen

Reputation: 322

You need to have your python 3.7 version in your path variable higher than that 3.6 version.

Upvotes: 2

Related Questions