欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

pip安装库用回官方源,检查库内提供的版本

程序员文章站 2022-05-07 23:08:16
...

今天自己更新了自己的库到pypi以后,发现无法更新到最新的版本,清华和豆瓣的国内源迟迟不同步
我的国内源配置如下(git bash)

[email protected] MINGW64 ~
$ cat pip/pip.ini
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

使用pip安装,可以看到如下版本信息

C:\Users\admin>pip install -U ssh-lite==
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting ssh-lite==
  Could not find a version that satisfies the requirement ssh-lite== (from versions: 1.1, 1.2, 1.4)
No matching distribution found for ssh-lite==
You are using pip version 18.1, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

可以看到最新同步过去的版本是1.4版本,而我实际上已经更新到了1.7版本

两种解决办法

  • 暴力的方式,暂时改掉pip.ini,安装后再改回来,可以看到1.7版本
[email protected] MINGW64 ~
$ mv pip/pip.ini pip/pip.ini_bak

[email protected] MINGW64 ~
$ pip install -U ssh-lite==	 # 在这里去掉==,即可安装最新版本
Collecting ssh-lite==
  Could not find a version that satisfies the requirement ssh-lite== (from versions: 1.1, 1.2, 1.4, 1.5, 1.7)
No matching distribution found for ssh-lite==
You are using pip version 18.1, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

[email protected] MINGW64 ~
$ mv pip/pip.ini_bak pip/pip.ini
  • 也可以用-i来指定镜像,临时绕开国内镜像,也可看到最新版本。只不过这个镜像要正确指定,而竟然没有查到任何文章说明这个问题,我是实验得出,特此记录
C:\Users\admin>pip install -U ssh-lite== -i https://pypi.org/simple
Collecting ssh-lite==
  Could not find a version that satisfies the requirement ssh-lite== (from versions: 1.1, 1.2, 1.4, 1.5, 1.7)
No matching distribution found for ssh-lite==
You are using pip version 18.1, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

要点:路径为simple,且服务的地址是pypi.org,而不是实际下载的files.pythonhosted.org