Ubuntu 16.04 LTS下matplotlib安装出错
使用命令sudo pip3 install matplotlib已知报错,用同样的命令安装numpy和opencv却没有,因此重装linux系统两次都没有解决(我是在Vmware中创建的)。报错如下:
- rogn@ubuntu:~$sudo pip3 install matplotlib
- Collecting numpy
- Exception:
- Traceback (most recent call last):
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 137, in _new_conn
- (self.host, self.port), self.timeout, **extra_kw)
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 91, in create_connection
- raise err
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 81, in create_connection
- sock.connect(sa)
- OSError: [Errno 101] Network is unreachable
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 560, in urlopen
- body=body, headers=headers)
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
- self._validate_conn(conn)
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 787, in _validate_conn
- conn.connect()
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 217, in connect
- conn = self._new_conn()
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 146, in _new_conn
- self, "Failed to establish a new connection: %s" % e)
- requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3bbaa12198>: Failed to establish a new connection: [Errno 101] Network is unreachable
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
- status = self.run(options, args)
- File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 328, in run
- wb.build(autobuilding=True)
- File "/usr/lib/python3/dist-packages/pip/wheel.py", line 748, in build
- self.requirement_set.prepare_files(self.finder)
- File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
- ignore_dependencies=self.ignore_dependencies))
- File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
- finder, self.upgrade, require_hashes)
- File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
- self.link = finder.find_requirement(self, upgrade)
- File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
- all_candidates = self.find_all_candidates(req.name)
- File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
- for page in self._get_pages(url_locations, project_name):
- File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
- page = self._get_page(location)
- File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
- return HTMLPage.get_page(link, session=self.session)
- File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
- "Cache-Control": "max-age=600",
- File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in get
- return self.request('GET', url, **kwargs)
- File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
- return super(PipSession, self).request(method, url, *args, **kwargs)
- File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 468, in request
- resp = self.send(prep, **send_kwargs)
- File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 576, in send
- r = adapter.send(request, **kwargs)
- File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send
- resp = super(CacheControlAdapter, self).send(request, **kw)
- File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send
- timeout=timeout
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen
- _stacktrace=sys.exc_info()[2])
- File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 228, in increment
- total -= 1
- TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
- You are using pip version 8.1.1, however version 19.0.3 is available.
- You should consider upgrading via the 'pip install --upgrade pip' command.
可能当时太冲动,没有考虑太多网络问题,仔细看报错,第一个就是。
解决方法
网络问题,解决方案很简单,不用官方源改用阿里镜像。命令如下:
- sudo pip3 install matplotlib -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
效果如下:
- rogn@ubuntu:~$ sudo pip3 install matplotlib -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- The directory '/home/rogn/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
- The directory '/home/rogn/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
- Collecting matplotlib
- Downloading http://mirrors.aliyun.com/pypi/packages/ad/4c/0415f15f96864c3a2242b1c74041a806c100c1b21741206c5d87684437c6/matplotlib-3.0.2-cp35-cp35m-manylinux1_x86_64.whl (12.9MB)
- 100% |████████████████████████████████| 12.9MB 11.4MB/s
- Collecting kiwisolver>=1.0.1 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/7e/31/d6fedd4fb2c94755cd101191e581af30e1650ccce7a35bddb7930fed6574/kiwisolver-1.0.1-cp35-cp35m-manylinux1_x86_64.whl (949kB)
- 100% |████████████████████████████████| 952kB 27.3MB/s
- Collecting cycler>=0.10 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
- Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/de/0a/001be530836743d8be6c2d85069f46fecf84ac6c18c7f5fb8125ee11d854/pyparsing-2.3.1-py2.py3-none-any.whl (61kB)
- 100% |████████████████████████████████| 71kB 14.8MB/s
- Requirement already satisfied (use --upgrade to upgrade): numpy>=1.10.0 in /usr/local/lib/python3.5/dist-packages (from matplotlib)
- Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2.1 in /usr/local/lib/python3.5/dist-packages (from matplotlib)
- Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python3/dist-packages (from kiwisolver>=1.0.1->matplotlib)
- Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python3/dist-packages (from cycler>=0.10->matplotlib)
- Installing collected packages: kiwisolver, cycler, pyparsing, matplotlib
- Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.2 pyparsing-2.3.1
- You are using pip version 8.1.1, however version 19.0.3 is available.
- You should consider upgrading via the 'pip install --upgrade pip' command.
就是网络慢,有时候可以慢速下载,有时直接连接失败, 好像科学上网也不行,不知道pip3的--timeout选项变大点会不会好点。(不吐槽了,换源大法好!
Windows下同样的问题
当出现这一问题,我的Visual Studio 2017的Python3板块下使用命令pip3 install matplotlib也出错,报错如下:
- C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>pip3 install matplotlib
- Collecting matplotlib
- Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/matplotlib/
- Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/matplotlib/
- Using cached https://files.pythonhosted.org/packages/b1/56/569c83515c10146fd0aa09e086816b12e301d0811048e3354a6e9b77ba9a/matplotlib-3.0.2-cp36-cp36m-win_amd64.whl
- Requirement already satisfied: numpy>=1.10.0 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from matplotlib) (1.16.1)
- Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
- Could not find a version that satisfies the requirement pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib) (from versions: )
- No matching distribution found for pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
- You are using pip version 19.0.2, however version 19.0.3 is available.
- You should consider upgrading via the 'python -m pip install --upgrade pip' command.
同样也是网络问题,用上面同样的方法:
- C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>pip install matplotlib -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
- Collecting matplotlib
- Downloading http://mirrors.aliyun.com/pypi/packages/b1/56/569c83515c10146fd0aa09e086816b12e301d0811048e3354a6e9b77ba9a/matplotlib-3.0.2-cp36-cp36m-win_amd64.whl (8.9MB)
- 100% |████████████████████████████████| 8.9MB 11.4MB/s
- Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/de/0a/001be530836743d8be6c2d85069f46fecf84ac6c18c7f5fb8125ee11d854/pyparsing-2.3.1-py2.py3-none-any.whl (61kB)
- 100% |████████████████████████████████| 71kB 3.8MB/s
- Collecting cycler>=0.10 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
- Requirement already satisfied: numpy>=1.10.0 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from matplotlib) (1.16.1)
- Collecting python-dateutil>=2.1 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
- 100% |████████████████████████████████| 235kB 17.1MB/s
- Collecting kiwisolver>=1.0.1 (from matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/44/72/16630c3392eba03788ad87949390516bbc488e8e118047a3b824631d21a6/kiwisolver-1.0.1-cp36-none-win_amd64.whl (57kB)
- 100% |████████████████████████████████| 61kB 5.6MB/s
- Collecting six (from cycler>=0.10->matplotlib)
- Downloading http://mirrors.aliyun.com/pypi/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
- Requirement already satisfied: setuptools in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)
- Installing collected packages: pyparsing, six, cycler, python-dateutil, kiwisolver, matplotlib
- Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'c:\\program files (x86)\\microsoft visual studio\\shared\\python36_64\\Lib\\site-packages\\pyparsing.py'
- Consider using the `--user` option or check the permissions.
- You are using pip version 19.0.2, however version 19.0.3 is available.
- You should consider upgrading via the 'python -m pip install --upgrade pip' command.
附加:
- 阿里云 http://mirrors.aliyun.com/pypi/simple/
- 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣(douban) http://pypi.douban.com/simple/
- 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
参考链接:https://blog.csdn.net/qq_25964837/article/details/80295041
Ubuntu 16.04 LTS下matplotlib安装出错的更多相关文章
- 在Ubuntu 16.04 LTS下编译安装OpenCV 4.1.1
目录 一 安装前的准备 二 编译并安装OpenCV 4.1.1 注:原创不易,转载请务必注明原作者和出处,感谢支持! OpenCV目前(2019-8-1)的最新版本为4.1.1.本文将介绍如何在Ubu ...
- Ubuntu 16.04 LTS U盘安装要点
一.UltraISO UltraISO是一款功能强大而又方便实用的光盘映像文件制作/编辑/转换工具,它可以直接编辑ISO文件和从ISO中提取文件和目录,也可以从CD-ROM制作光盘映像或者将硬盘上的文 ...
- Ubuntu 16.04 LTS 下安装MATLAB2015b 以及Matlab system error解决办法
下载MATLAB2015b破解版 操作系统:Ubuntu 16.o4 LTS 程序文件:Matlab2015b-glnxa64破解版 解压提取文件:在ubuntu系统下可以直接提取压缩文件,得到三个文 ...
- Ubuntu 16.04 LTS 下安装 ibus-rime 输入法
搜 Linux 下粤拼输入法的时候发现了 Rime,由于 fcitx 下的拼音输入体验实在不太好(搜狗是在我的电脑上完全坏掉了,调不出来,配置文件的问题一直没解决:谷歌是好过没有),于是安装 ibus ...
- OpenCL科普及在ubuntu 16.04 LTS上的安装
OpenCL(Open Computing Language,开放计算语言)是一个为异构平台编写程序的框架,此异构平台可由CPU.GPU.DSP.FPGA或其他类型的处理器與硬體加速器所组成.Open ...
- 在 Ubuntu 16.04 LTS 上 离线安装 Docker / Docker-compose
前情提要 今天上班后,突然接到现场的工程师的电话: XXX的现场环境组的的局域网,上不了互联网.bla bla bla..... 如果需要安装其他软件的话,只能是自己带过去安装... 听完现场工程师的 ...
- Linux从入门到适应(四):Ubuntu 16.04环境下,安装Nvidia驱动,cuda9.2和 cudnn
在安装深度学习框架之前,cuda和cudnn是必须要提前安装的,现在按照流程而nvidia驱动的版本和cuda版本有这一些对应关系,所以需要按照版本进行安装,现在说一下如何安装: 1 安装nvidia ...
- Ubuntu 16.04 LTS运行robo3t报错
系统环境:Ubuntu 16.04 LTS. 安装robomongo Robo 3T,运行时报以下错误: jaxu@jaxu-ubuntu:/usr/local/share/robo3t--linux ...
- VMware Workstation 14 PRO 下安装Ubuntu 16.04 LTS教程
一.准备好安装的VMware Workstation 14 PRO 1.VMware Workstation 14 PRO下载链接:http://rj.baidu.com/soft/detail/13 ...
随机推荐
- mac上python3安装HTMLTestRunner
下载支持python3版本的HTMLTestRunner.py文件后,拷贝到python3的lib目录下 在终端输入如下命令: 将HTMLTestRunner.py文件拷贝到如下目录后,pycharm ...
- PhpStorm比较高级的一些设置
开始使用phpstorm工具,总体感觉还是不错的.有点不舒服的就是他占用内存比较高,反应速度有时会卡,这跟他的功能强大有关系.有些功能对于 我来说是不怎么需要的,比如自动保存功能,会频繁的保存一些文件 ...
- 【203】利用UltraISO制作和刻录光盘映像的方法
参考:利用UltraISO制作和刻录光盘映像的方法 软件:UltraISO注册版(制作镜像).rar 目录: 1.利用UltraISO制作光盘映像2.利用UltraISO刻录光盘映像文件 1.利用Ul ...
- k8s-部署dashboard1.10.1-十七
一.获取镜像和填坑 我的k8s是1.13.1,这里dashboard用的1.10.1: 由于国内不能访问Google,而且大部分人可能也没有其他途径访问:只能在阿里云或者其他镜像网站上获取了: 镜像获 ...
- Nginx: 统计PV、UV、独立IP
1.概念: UV(Unique Visitor):独立访客,将每个独立上网电脑(以cookie为依据)视为一位访客,一天之内(00:00-24:00),访问您网站的访客数量.一天之内相同cookie的 ...
- Eclipse中快速重写(Override)基类方法的技巧(转载)
转自:http://blog.csdn.net/guolin_blog/article/details/11952435 在Android开发过程中会引用大量的标准库,还要通过Override基类函数 ...
- 一文教您如何通过 Docker 快速搭建各种测试环境(Mysql, Redis, Elasticsearch, MongoDB) | 建议收藏
欢迎关注个人微信公众号: 小哈学Java, 文末分享阿里 P8 高级架构师吐血总结的 <Java 核心知识整理&面试.pdf>资源链接!! 个人网站: https://www.ex ...
- Codeforces630C【水题】
题意: 有一种数只会有7或者8构成,给一个n,问你前n位上有多少个这样的数. 思路: 对于一个 i 位,有2^i个数,然后前n项和就是2^(n+1)-2; 复习一下等比数列求和,等差数列求和吧; ①: ...
- [Shader 着色器]冰霜效果的思考和实现
http://game.ceeger.com/forum/read.php?tid=23209&fid=2 由于最近要做一个冰系的角色,就想能不能做一些冰霜效果.那么就试试吧,先弄一张原图: ...
- js中的预解释
在js中,带var 和function关键字的需要预解释: 那什么是预解释?就是在js代码执行之前,先申明好带有var 关键字和带有function关键字的变量,在内存里先安排好.但是带有var关键字 ...