鱼C论坛

 找回密码
 立即注册
查看: 3512|回复: 25

[已解决]如何安装matplotlib

[复制链接]
发表于 2020-10-16 23:04:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
看了书上和网上的方法,都装不上。特此求助有经验的网友如何在当前python版本中安装matplotlib

我在cmd查看到python版本:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

我下了文件matplotlib-3.3.2-cp38-cp38-win32.whl。然后按书上的方法没法装上
报错代码如下:
ERROR: matplotlib-3.3.2-cp38-cp38-win32.whl is not a supported wheel on this platform.
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'C:\Users\asus\AppData\Local\Programs\Python\Python38\python.exe -m pip install --upgrade pip' command.
最佳答案
2020-10-17 00:16:28
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

有网的情况下,除了某些原因外,还是pip更方便,内网的话只能下载后安装

看着报错,就是先升级pip到20.2.3,然后再安装matplotlib
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-10-16 23:13:16 | 显示全部楼层
cmd命令行
cd切到这个目录
C:\Users\asus\AppData\Local\Programs\Python\Python38\
输入
python.exe -m pip install --upgrade pip
更新pip先
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-16 23:18:29 | 显示全部楼层
昨非 发表于 2020-10-16 23:13
cmd命令行
cd切到这个目录

更新pip也报错了,哭了
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 454, in read
    n = self.readinto(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
    status = self.run(options, args)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\commands\install.py", line 324, in run
    requirement_set = resolver.resolve(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 282, in _download_http_url
    for chunk in download.chunks:
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\progress_bars.py", line 168, in iter
    for x in it:
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'C:\Users\asus\AppData\Local\Programs\Python\Python38\python.exe -m pip install -
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-16 23:23:15 | 显示全部楼层
张图南 发表于 2020-10-16 23:18
更新pip也报错了,哭了
ERROR: Exception:
Traceback (most recent call last):

看你报错的最后一行,把它的提示复制全,然后在当前目录下执行
python.exe -m pip install -(后面补全)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-16 23:29:03 | 显示全部楼层
昨非 发表于 2020-10-16 23:23
看你报错的最后一行,把它的提示复制全,然后在当前目录下执行

补全了也报错。我太难了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-16 23:33:10 | 显示全部楼层
张图南 发表于 2020-10-16 23:29
补全了也报错。我太难了

复制报错过来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-16 23:34:24 | 显示全部楼层

C:\Users\asus\AppData\Local\Programs\Python\Python38>python.exe -m pip install --upgrade pip
Collecting pip
  Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
     |██                              | 102 kB 2.9 kB/s eta 0:08:03ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 454, in read
    n = self.readinto(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
    status = self.run(options, args)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\commands\install.py", line 324, in run
    requirement_set = resolver.resolve(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\operations\prepare.py", line 282, in _download_http_url
    for chunk in download.chunks:
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\progress_bars.py", line 168, in iter
    for x in it:
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'C:\Users\asus\AppData\Local\Programs\Python\Python38\python.exe -m pip install --upgrade pip' command.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-16 23:38:21 | 显示全部楼层
张图南 发表于 2020-10-16 23:34
C:%users\asus\AppData\Local\Programs\Python\Python38>python.exe -m pip install --upgrade pip
Coll ...

超时了,可能需要换源
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-16 23:39:38 | 显示全部楼层
昨非 发表于 2020-10-16 23:38
超时了,可能需要换源

怎么换源啊?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-16 23:40:09 | 显示全部楼层
看看这个有没有用
Python cmd用法大全 pip install和镜像
https://fishc.com.cn/thread-180234-1-1.html
(出处: 鱼C论坛)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-16 23:43:16 | 显示全部楼层
这问题我没亲身遇到过,你来看看?@疾风怪盗
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:14:45 | 显示全部楼层
pip 安装第三方库速度太慢
可设置 pip 从国内的镜像源下载安装

阿里云 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/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

设置方法,以清华镜像源为例:

临时使用

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxxxxxx

永久设置

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:16:28 | 显示全部楼层    本楼为最佳答案   
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

有网的情况下,除了某些原因外,还是pip更方便,内网的话只能下载后安装

看着报错,就是先升级pip到20.2.3,然后再安装matplotlib
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:17:04 | 显示全部楼层
昨非 发表于 2020-10-16 23:43
这问题我没亲身遇到过,你来看看?@疾风怪盗

我也没遇到过。。。。。之前有遇到pip需要更新的提示,然后更新了就好了。。。。。没遇到matplotlib不能安装的问题。。。。。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:20:30 | 显示全部楼层
疾风怪盗 发表于 2020-10-17 00:17
我也没遇到过。。。。。之前有遇到pip需要更新的提示,然后更新了就好了。。。。。没遇到matpl ...

超时换源啥的,我是听说过,没办法啦
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:37:07 | 显示全部楼层
昨非 发表于 2020-10-17 00:20
超时换源啥的,我是听说过,没办法啦

换源就使用清华镜像源啊,就是加个-i的参数,其实是一样的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 00:38:23 From FishC Mobile | 显示全部楼层
疾风怪盗 发表于 2020-10-17 00:37
换源就使用清华镜像源啊,就是加个-i的参数,其实是一样的

哦,受教了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-17 19:05:19 | 显示全部楼层
疾风怪盗 发表于 2020-10-17 00:16
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

有网的情况下,除了某些原因 ...

我升级了pip,但是按照书上的方法行不通啊。大佬能教教我怎么安装matplotlib吗
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-17 19:13:20 | 显示全部楼层
张图南 发表于 2020-10-17 19:05
我升级了pip,但是按照书上的方法行不通啊。大佬能教教我怎么安装matplotlib吗

什么叫书上的方法?你的pip现在版本是多少?
然后用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib
,报错是什么?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-17 19:13:45 | 显示全部楼层
张图南 发表于 2020-10-17 19:05
我升级了pip,但是按照书上的方法行不通啊。大佬能教教我怎么安装matplotlib吗

感谢大佬。我已经成功换源更新了pip。再次尝试了一下安装matplotlib就按照上了
C:\Users\asus\AppData\Local\Programs\Python\Python38>pip install matplotlib
Downloading https://pypi.tuna.tsinghua.edu.c ... y2.py3-none-any.whl (10 kB)
Installing collected packages: numpy, six, python-dateutil, pyparsing, pillow, kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.3.2 numpy-1.19.2 pillow-8.0.0 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0
再次向您表达诚挚的谢意
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-18 07:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表