在python环境中,有些开发需要依赖于python3的安装包,然而有些又需要python2才能运行。索性将python2和python3同时安装,并配置好各自的运行方式,以及各版本的pip。方便在需要安装工具包的时候,能准确定位到相应的版本。
安装python后添加系统变量
将python和python-Script都加入环境变量中

修改python.exe和pythonw.exe的文件名
找到python2和python3的安装目录,修改各自的python.exe、pythonw.exe分别
为python2.exe、pythonw2.exe和python3.exe、pythonw3.exe


在cmd命令上查看不同的版本
分别输入python2 和 python3 可以查看使用不同版本的python

pip双版本共存
Python 安装包需要用到包管理工具pip,重新安装两个版本的pip,使得两个python版本的pip能够共存
重新安装pip3:
python3 -m pip install --upgrade pip --force-reinstall
重新安装pip2:
python2 -m pip install --upgrade pip --force-reinstall
pipX -V查看pip版本信息
可以通过pip2 -V
和pip3-V
查看两个版本的pip信息,

以后只需运行
pip2 install XXX
pip3 install XXX
即可安装各自的python包
网友评论