When Python2 and Python3 are installed at the same time in the computer, it is often the need to switch versions. So how do you do it with the cmd command line?
Method: Modify the file name of the Python.exe
Give me a chestnut:
Both py2.7.10 and python3.4.3 are installed in My computer, and the following paths are added to the path path of the system environment variable, which is configured with the environment variables:
E:\python2.7.10_64\;E:\python2.7.10_64\Scripts;E:\python3.4.3\;E:\python3.4.3\Scripts;
The two paths point to the Python installation directory E:\python2.7.10_64 and E:\python3.4.3, respectively, such as:
- If I want to use the Python3 version, just rename the Python.exe in the Python2 installation directory to Python2.exe, such as:
When I enter "python–version" in command line cmd, I see that I have switched to the Python3 version, such as:
2. If I want to use the Python2 version, simply rename the Python.exe in the Python3 installation directory to Python3.exe, such as:
When I enter "python–version" in command line cmd, I see that I have switched to the Python2 version, such as:
-
Note points for using the PS:PIP command:
-
(1). When only Python2 or Python3 are installed, use PIP
-
(2) When installing both Python2 and Python3:
Python2 using PIP2
Python3 using PIP3
Switch Python2 and Python3 versions via cmd under "Turn" windows