我所遇到的问题:
在windows下,使用pycharm工具,直接在工具的Terminal 中安装python包,提示:
You are using pip version 10.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
在Pycharm的Terminal中直接运行python -m pip install --upgrade pip,报错,安装不成功:
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
****
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
那应该如何升级呢?
正确的做法如下:
找到virtualenv所在的目录,windows下一般在
C:\Users\[your_user_name]\.virtualenvs\[your_virtual_env_name]\
打开windows的命令行程序,跳转到虚拟环境目录下的Scripts目录,运行:
activate.bat
运行安装命令
python -m pip install --upgrade pip
如果报错,应该是由于之前在pycharm中错误的安装,导致系统认为你已经升级过pip,那么就需要进入到:
C:\Users\[your_user_name]\.virtualenvs\[your_virtual_env_name]\Lib\site-packages
在该目录下,删除之前升级失败的新版本pip的目录pip-20.0.2.dist-info(目录名由你自己的版本来确定,但目录开头是pip)
删除后,再次运行:
python -m pip install --upgrade pip
如果看到如下信息,表示已经安装成功:
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-20.0.2
网友评论