Window 中安装python多版本环境

时间:2021-10-18 07:35:17

由于python 3 已是目前稳定,且是将来版本版本。新学者可以直接从python3入手学习。但是目前还有很多企业级应用使用的是python 2,可能还得要维护。所以,我们在本地windows中可以安装python多版本,进行熟悉。

一:下载 python 3

官网地址:https://www.python.org

二:安装 python 3

安装时,勾选“Add Python 3.x to PATH” 或者安装后配置环境变量

三:配置

1.修改python.exe

将安装目录下的 C:\Python35\python.exe 改名为 python3.exe

2.修改 pip.exe

将python 3 中的 C:\Python35\Scripts\pip.exe 删掉

3.更新 pip

C:\WINDOWS\System32>pip3
Fatal error in launcher: Unable to create process using '"'

如果出现上方错误提示,则重新更新python3 的pip 即可,命令如下

C:\WINDOWS\System32>python3 -m pip install -U pip
Collecting pip
Downloading pip-8.1.-py2.py3-none-any.whl (.2MB)
% |███████████▏ | 419kB 117kB/s eta ::
Successfully installed pip-8.1.

四:检查安装情况

C:\WINDOWS\System32>python -V
Python 2.7. C:\WINDOWS\System32>python3 -V
Python 3.5. C:\WINDOWS\System32>pip -V
pip 1.5. from C:\Python27\lib\site-packages (python 2.7) C:\WINDOWS\System32>pip3 -V
pip 8.1. from c:\python35\lib\site-packages (python 3.5) C:\WINDOWS\System32>where python
C:\Python27\python.exe C:\WINDOWS\System32>where python3
C:\Python35\python3.exe

python -m pip install --upgrade pip

C:\Users\Administrator>pip3 --version
pip 1.5. from D:\360YP\VM\python2.\lib\site-packages (python 2.7) C:\Users\Administrator>python -m pip --version
pip 1.5. from D:\360YP\VM\python2.\lib\site-packages (python 2.7) C:\Users\Administrator>python -m pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408
f196358da3/pip-9.0.-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
Installing collected packages: pip
Found existing installation: pip 1.5.
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up... C:\Users\Administrator>pip --version
pip 9.0. from D:\360YP\VM\python2.\lib\site-packages (python 2.7) C:\Users\Administrator>pip3 --version
pip 9.0. from d:\360yp\vm\python35\lib\site-packages (python 3.5)

Window 中安装python多版本环境

***微信扫一扫,关注“python测试开发圈”,了解更多测试教程!***