今天自己更新了自己的庫到pypi以後,發現無法更新到最新的版本,清華和豆瓣的國內源遲遲不同步
我的國內源配置如下(git bash)
admin@DESKTOP-36Q0EK4 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版本
admin@DESKTOP-36Q0EK4 MINGW64 ~
$ mv pip/pip.ini pip/pip.ini_bak
admin@DESKTOP-36Q0EK4 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.
admin@DESKTOP-36Q0EK4 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