一, 问题如下:
1, 截图:
2, 错误信息:
- Could not find a version that satisfies the requirement re (from versions: )
- No matching distribution found for re
3, 翻译:
找不到满足 re 要求的版本 (来自版本: ) 找不到 re 的匹配分布
二, 解决方法:
1, 采用国内镜像则能够提高安装成功率并提速:
http://mirrors.aliyun.com/pypi/simple/
| 阿里云 |
https://pypi.mirrors.ustc.edu.cn/simple/
| 中国科技大学 |
http://pypi.douban.com/simple/
| 豆瓣 |
https://pypi.tuna.tsinghua.edu.cn/simple/
| 清华大学 |
使用方法:
pip3 install -i http://pypi.tuna.tsinghua.edu.cn/simple re
可能会出现如下问题:
- The repository located at pypi.tuna.tsinghua.edu.cn is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.tuna.tsinghua.edu.cn'.
- Could not find a version that satisfies the requirement re (from versions: )
- No matching distribution found for re
Linux 系统:
在~/.pip/pip.conf (若没有此文件自行创建文件夹要加 ".", 表示是隐藏文件夹) 中设置以下内容:
- [global]
- index-url = https://pypi.tuna.tsinghua.edu.cn/simple
- [install]
- trusted-host=mirrors.aliyun.com
Windows 系统:
直接在 user 目录中创建一个 pip 目录, 如: C:\Users\lenovo\pip, 新建文件 pip.INI, 设置以下内容:
- [global]
- index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2, 在网站上下载第三方库的离线包, 离线安装:
网上收集的集合网站:
- Linux(主要提供 Linux 版本的后缀是 ".whl" 和 ".tar.gz"):
- https://pypi.org/
- Windows(主要提供 Windows 版本的后缀是 ".whl"):
- https://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow
- https://pypi.org/simple/
python 的离线安装, 有时候由于不同模块有很多依赖包, 所以很容易出错, 在线安装会自动安装依赖包, 所以一般不会出现安装问题.
离线安装方法,".whl" 文件安装如下:
此处以 ujson 为例:
Linux 版本的安装 (默认文件在当前目录下)
pip3 install ujson 的 whl 文件名
我没有 Linux 版本, 这里只列一下代码.
Windows 版本的安装 (默认文件在当前目录下)
pip3 install ujson1.35cp36cp36mwin_amd64.whl
安装时又出现了问题:
ujson-1.35-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
意思就是说 whl 名的命名不符合它给的规范.
在 python 中使用以下命令:
32 位:
- import pip
- print(pip.pep425tags.get_supported())
64 位:
- import pip._internal
- print(pip._internal.pep425tags.get_supported())
结果如下:
支持里有个:('cp36', 'cp36m', 'win32'),
下的 whl 名字是: ujson-1.35-cp36-cp36m-win_amd64.whl, 这是无法安装的, 我改为: ujson-1.35-cp36-cp36m-win32.whl, 就好了. 如果是 python2.7 的, 很可能库里存在兼容性问题.
将下载的文件重命名为:
之后就是安装成功:
可以看到在自己 python 路径下的 Lib\site-packages 文件夹下, 看到 ujson 文件夹已经存在, 到此安装完毕:
推荐使用离线的方式, 在线的不怎么靠谱, 毕竟是国外网站, 有时候一直连不上也是常事.
来源: https://www.cnblogs.com/guobin-/p/10688738.html