鱼C论坛

 找回密码
 立即注册
查看: 2054|回复: 4

No module named 'matplotlib'

[复制链接]
发表于 2019-11-17 10:41:56 | 显示全部楼层 |阅读模式

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

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

x
请问 matplotlib 在Mac上怎么安装呀?我已经安装了anaconda,上网查了之后,在终端里输入sudo pip install --upgrade --ignore-installed matplotlib
结果显示不成功。求助各位,谢谢!

终端显示结果:
(base) MacdeMacBook-Air:~ mac$ sudo pip install --upgrade --ignore-installed matplotlib
Password:
WARNING: The directory '/Users/mac/Library/Caches/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.
WARNING: The directory '/Users/mac/Library/Caches/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 https://files.pythonhosted.org/p ... sx_10_10_x86_64.whl (14.4MB)
     |████████████████████████████████| 14.4MB 771kB/s
Collecting kiwisolver>=1.0.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/p ... sx_10_10_x86_64.whl (113kB)
     |████████████████████████████████| 122kB 11.9MB/s
Collecting cycler>=0.10 (from matplotlib)
  Downloading https://files.pythonhosted.org/p ... y2.py3-none-any.whl
Collecting numpy>=1.11 (from matplotlib)
  Downloading https://files.pythonhosted.org/p ... osx_10_9_x86_64.whl (15.1MB)
     |████████████████████████████████| 15.1MB 3.4MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/p ... y2.py3-none-any.whl (67kB)
     |████████████████████████████████| 71kB 10.9MB/s
Collecting python-dateutil>=2.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/p ... y2.py3-none-any.whl (227kB)
     |████████████████████████████████| 235kB 9.5MB/s
Collecting setuptools (from kiwisolver>=1.0.1->matplotlib)
  Downloading https://files.pythonhosted.org/p ... y2.py3-none-any.whl (582kB)
     |████████████████████████████████| 583kB 13.5MB/s
Collecting six (from cycler>=0.10->matplotlib)
  Downloading https://files.pythonhosted.org/p ... y2.py3-none-any.whl
ERROR: astroid 2.3.1 requires typed-ast<1.5,>=1.4.0; implementation_name == "cpython" and python_version < "3.8", which is not installed.
ERROR: astroid 2.3.1 has requirement six==1.12, but you'll have six 1.13.0 which is incompatible.
      我安装的是3.8的python
Installing collected packages: setuptools, kiwisolver, six, cycler, numpy, pyparsing, python-dateutil, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.1 numpy-1.17.4 pyparsing-2.4.5 python-dateutil-2.8.1 setuptools-41.6.0 six-1.13.0

我的代码:
import csv

from matplotlib import pyplot as plt
from datetime import datatime

filename = 'death_valley_2018_full.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)

    dates.highs,lows =[],[],[]
    for row in reader:
        date=datetime.striptime(row[0],'%Y-%m-%d')
        dates.append(date)
        highs.append(row[6])
        lows.append(row[7])
    print(highs,lows)


fig = plt.figure()
plt.plot(dates,highs,c ='red')
plt.plot(dates,lows,c ='blue')

plt.title('daily temperatures,2018',fontsize=24)
plt.xlabel('date',fontsize=16)
plt.ylabel('temperature',fontsize=16)
plt.tick_params(axis='both',which='major',labelsize=16)

plt.show()


运行结果:
Traceback (most recent call last):
  File "/Users/mac/Desktop/2.py", line 3, in <module>
    from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2019-11-17 10:56:00 | 显示全部楼层
请问这样是成功了吗  但运行代码还是不行
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.1 numpy-1.17.4 pyparsing-2.4.5 python-dateutil-2.8.1 six-1.13.0
You are using pip version 18.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-11-17 11:39:36 | 显示全部楼层
电脑里已经安装了anaconda-navigator
哎。。还是不行啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-11-17 19:25:40 | 显示全部楼层
zpx1002 发表于 2019-11-17 11:39
电脑里已经安装了anaconda-navigator
哎。。还是不行啊

提示告诉你让你升级Pip。

You should consider upgrading via the 'pip install --upgrade pip' command.

运行这个命令试试。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-11-17 19:39:33 | 显示全部楼层
heidern0612 发表于 2019-11-17 19:25
提示告诉你让你升级Pip。

You should consider upgrading via the 'pip install --upgrade pip' comma ...

谢谢,这个帖子之前没通过审核。。
我在这里问了
https://fishc.com.cn/forum.php?m ... p;page=2#pid4195494

最后我决定用spyder运行代码,没报错

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-12 20:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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