Foreword:
Recently, due to work requirements, I have to play Python in different environments, so I have the above requirements. After checking some information, I summarize and record the solution process of the whole problem, so that the latecomers can avoid pitfalls.
Reference: https://blog.csdn.net/dream_an/article/details/51248736
Reference: https://blog.csdn.net/sinat_36246371/article/details/55251854
First of all, to switch between different versions, you must first download a different Python version. The whole steps are as follows:
1. Download Python2.7x and Python3.5x versions
N words are omitted here. . .
2. Install Python2.7x and Python3.5x versions
It's very simple, just click install, pay attention to the installation location, my installation location is E:\IDES\Python27\ and E:\IDES\Python35
3. Configure the environment variables and add the following to the path path respectively
4. Only modify the .exe file in the Python27 (E:\IDES\Python27) file (the system defaults to Python3.5)
Change python.exe to python2.exe (after declaring the environment variable, when entering the relevant command, it will go to the directory specified by the corresponding environment variable to start the corresponding script. At this time, if the names of the startup scripts corresponding to Python2 and Python3 are the same , the system will report an error. So it is necessary to change the names of the two startup scripts to be different)
5. How to call Python2.7 and Python3.5 respectively in cmd
5.1. Enter Python2 to call Python2.7 version
5.2. Enter Python to call Python 3.5 version
Next, let's talk about how Pycharm switches between different versions:
1. Open the File menu and select Settings:
2. After opening the Settings window, select the Porject Interpreter under Project: prjectName, and the following image will appear:
Finally, select the desired Python version number from the Porject Interpreter drop-down menu on the right side of the window. (Note: The virtual Python environment can be edited in the Pycharm environment, just like a project corresponds to a Python environment, as long as you edit it, when you load the project again, the corresponding environment will be loaded together, no need to manually switch. environment)