Fix pip Cannot Find Correct Version

1. Problem description

This problem is very strange. Confirm that the package name and version are correct. When installing, it prompts that it cannot be found:

Text
1
2
3
4
5
6
7
8
$ btpip install flask==2.2.2

Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
WARNING: The repository located at mirrors.tencentyun.com is not a trusted or secure host and is being ignited
ored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may sile
nce this warning and allow it anyway with '--trusted-host mirrors.tencentyun.com'.
ERROR: Could not find a version that satisfies the requirement flask==2.2.2
ERROR: No matching distribution found for flask==2.2.2

In fact, the solution to the problem has already been stated in the warning in the first paragraph: pip does not trust the software source.

2. Solution

2.1, temporary solution

Change the install command from

Bash
1
pip install <package>

changed to

Bash
1
pip install <package> --trusted-host <hostname>

For example:

Bash
1
pip install flask --trusted-host mirrors.tencentyun.com

2.2, change the source permanently

For software source selection and replacement, it is recommended to refer to the articles on this site:

Comparison of domestic software sources
https://blog.tsinbei.com/archives/238/
Server Optimization (2) Replacing Software Sources
https://blog.tsinbei.com/archives/237/

For example, to select https://mirrors.cloud.tencent.com, execute:

Bash
1
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple

This will permanently resolve the issue.

If the error is still reported, you can try a few more times and change to a different software source.

Fix pip Cannot Find Correct Version

https://blog.tsinbei.com/en/archives/703/

Author
Hsukqi Lee
Posted on

2023-05-18

Edited on

2023-05-18

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet