Python开发:部分第三方库无法在线安装解决方法
一、问题如下:
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”):
Windows(主要提供Windows版本的后缀是".whl"):
https://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow
python的离线安装,有时候由于不同模块有很多依赖包,所以很容易出错,在线安装会自动安装依赖包,所以一般不会出现安装问题。
离线安装方法,".whl"文件安装如下:
此处以ujson为例:
linux版本的安装(默认文件在当前目录下)
pip3 install ujson的whl文件名
我没有linux版本,这里只列一下代码。
Windows版本的安装(默认文件在当前目录下)
pip3 install ujson‑1.35‑cp36‑cp36m‑win_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文件夹已经存在,到此安装完毕:
推荐使用离线的方式,在线的不怎么靠谱,毕竟是国外网站,有时候一直连不上也是常事。
- 无法使用pip命令安装python第三方库的原因及解决方法
- ubuntu16.04无法安装第三方软件解决方法 、
- CentOS 7 GNOME桌面无法在线安装Shell扩展的解决方法
- sublime text3刚从官网下载安装后,Ctrl+B无法直接运行Python文件问题--解决方法
- Ubuntu 16.04无法安装第三方deb软件的解决方法
- centos6.8安装python3.7无法import _ssl的解决方法
- ubuntu下ulipad的安装及无法运行python3程序的解决方法
- Win7 VS2010下开发的CS软件,安装到XP下无法运行或者桌面快捷方式无法显示图标的问题解决方法
- Mac下安装与配置Go语言开发环境 无法写入系统文件的解决方法
- python2安装PIL等第三方库提示Python version 2.7 required, which was not found in the registry的解决方法
- macbook 安装windows8.1 开发windows phone无法使用模拟器的解决方法
- 对于Centos7,安装python3.6无法使用方向键问题的解决方法
- python安装第三方库时找不到“cl.exe”的解决方法(Win10系统)
- Centos 7 安装 Python3.6后yum无法使用的解决方法
- Python ImportError: No module named scrapy 成功安装scrapy,却无法import的解决方法
- deepin 安装idea(社区版),NetBeans 等开发软件无法正常显示中文字符的解决方法
- Android环境搭建——adt无法更新或者无法在线安装的解决方法
- 安装python第三方库:xlwt及出错ImportError: No module named setuptools的解决方法
- sqlserver 2005 开发斑安装,出现 "SQL Server 安装程序无法获取 ASPNET 帐户的系统帐户信息"的解决方法
- 自定义安装 Python 后,出现方向键无法用,按下方向键后,终端显示的式相应的字符编码,而不是方向键的功能的解决方法