Today I stumbled upon a strange phenomenon, I typed in CMDpythonWhen I looked at the version number, I found that the version number was python2.7. I had python3.7 installed. What a strange thing!My first reaction was to look at the environment variables. See the eyesThe user variablesNo problem! At the top of the list is python3.7!I went to have another lookSystem variables.

.; %JAVA_HOME%\bin; E:\Node.js; E:\Git\Git\cmd; C:\Users\yusael.atom\packages\uncrustify; E:\Matlab2014b\runtime\win64; E:\Matlab2014b\bin; E:\Matlab2014b\polyspace\bin; C: \ Program Files \ mingw (x86) – w64 \ i686-8.1.0 – posix – the dwarf – rt_v6 – rev0 \ mingw32 \ bin;; %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\system32\wbem; C:\Program Files\Intel\WiFi\bin; C:\Program Files\Common Files\Intel\WirelessCommon; E:\GoLand\Go\bin; E:\emacs\bin;

I’ve looked at it several times and I’m sure the word Python doesn’t even appear here!

Unconvinced, I tried several more times on the command line and found python2.7. So what’s the reason?

So here’s how I thought about it, how I solved it, and I thought it was kind of interesting, and I’m going to go back to rational thinking, and the computer doesn’t just have python2.7 out of nowhere, it has to be some environment variable that’s going wrong. So, I removed all python3.7 environment variables from the user variables.

If you go to the command line again, version 2.7 is still displayed.

Good! Make sure that user variables are not used, and at this point, I’m finally ready to solve a problem that has been bothering me for a long time, what’s the difference between a system variable and a user variable? This problem has bothered me since THE beginning of learning Java configuration environment variables, and today I finally know the difference between them!

In short, a system environment variable is an effect on all users; The user environment variable, on the other hand, only applies to the current user. More importantly, system variables are retrieved first, and user variables are not executed until the system is complete.

Thus, system variables take precedence over user variables.

Then there is no problem. I removed PYTHon3.7 as a user variable, but the Python instruction is still valid in CMD, indicating that there must be some Python2.7 environment variable hidden in the system variable. But there is no word for python!

Good! Do a search!All I got when I typed Python was python3.7, so I assumed python2.7 was not installed on my computer.

And then I hit a 2Oh, my god! Actually showing up! ? It looks like my computer does have python2.7 and its priority is higher than my 3.7, not a big deal, but I wonder where it is hiding.

Good! Let’s do it.Let’s find out where this little cutie is hiding!Ah? It’s in emcas. Emcas was installed on my computer by my classmate. I did not care much about this software. I can’t believe there’s a show onThe Italian job. I immediately deleted Emacs from the system variable and tried it. Sure enough!Now that I know what the problem is, the problem is solved: I moved Python from the user variable to the system variable, and put it ahead of Emacs, making it a higher priority, so that PYTHon3.7 is running in CMD.

Problem solved perfectly! This question mainly made me understand the difference between system variables and user variables, the most important is that the priority of system variables is higher than that of user variables.

Perhaps some people will think, why such a boring question to send a blog record?

No matter how small and insignificant the problem is, it is still a process of my thinking and exploration. Maybe one day someone will click on this article, frown, pause a little, then smile, and think: this article has solved a problem THAT I thought was very strange and lazy at that time

Only record ~