Install different versions of python on the same physical machine (including python installation steps)

One: Preface
Since the python3.x version is not compatible with the python2.x version, or the work involves development and testing between multiple versions of Python, or you need to use different versions of python to deal with different content, you need to Install two versions of Python on one physical machine (note: the same version of python, the same physical machine if and only if there can only be one).
Two: Specific installation and configuration steps
Take downloading python3.11 and python3.8 as an example:
Specific steps:
Step 1: Enter the python official website https://www.python.org, and download the installation of Python3.11 and python3.8 respectively Bag.
Step 2: Create a common folder python, place both python3.11 and python3.8 in this folder, but name them python311 and python38 respectively.
insert image description here
The same steps for different versions: download and install python3.8 and python3.11 (the picture shows Python. 8)
Step 1: Click the installer to install. The process is as follows:
insert image description here

insert image description here
insert image description here
Step 2: After the download is complete, click Close.
Do an important step: change the name to avoid duplicate names in different versions, and different names can call different versions of python.
(1) Open the python38 file, find python.exe and pythonw.exe. Rename them: python38.exe and pythonw38.exe.
insert image description here
(2) Open the python311 file, find python.exe and pythonw.exe. Rename them: python311.exe and pythonw311.exe.
Step 3: Open the CMD window and enter python38 -V or python38 –version (python311 -V or python311 –version) to view the corresponding version.
insert image description here
Note: The reason for the error in the red box in the figure is that the author wants to rename the python.exe and pythonw.exe files under the python311 folder, so the renaming must be done to avoid errors.

 第四步:若在安装时未勾选 “add python X to Path”,则需要手动添加环境变量。

insert image description here
Three: Unexpected situation
After all the above steps have been executed, are the students unable to hold back and want to gallop in the country of python and be with the world of mortals? It's a pity, the author can only tell you: You haven't woken up yet, have you? If the computer is so simple and easy to learn, the author will not let the once black and lush hair become "unsupported".
insert image description here
When we check the version of pip, what we get is not the answer we want, but shows: Fatal error in launcher: Unable to create process using '“D:\python\Python311\python.exe” “D:\python\ Python311\Scripts\pip3.exe "-version'.
What is this? This is because although we run python separately, we do not separate pip, so the next job is to separate pip.
Step 1: Download pip and upgrade
Python38: python38 -m pip install --upgrade pip --force-reinstall
insert image description here
Step 2: Find the pip installation directory Scripts file in python38. Rename the pip3.exe file in Scripts to pip38.exe.
insert image description here
Step 3: Test whether pip is available again.
insert image description here
Step 4: The operation of python311 is consistent:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_49769267/article/details/131526655