|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
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' |
|