安装anaconda和python3.7
安装matplotlib报错(参考https://github.com/conda/conda/issues/6007)
# 设置源为清华
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
D:\python\chuanzhi_15>conda install matplotlib
Solving environment: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
SSLError(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/repodata.json.bz2 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')))"))
解决办法:
Pycharm中配置cando环境
Page01.py文件:
# coding:utf-8
from matplotlib import pyplot as plt
x = range(2, 26, 2)
y = [15, 13, 14.5, 17,20,25,26,26,24,22,18,15]
plt.plot(x,y)
plt.show()
运行简单的画图效果程序报错:
D:\python\chuanzhi_15>python page01.py
Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in
from . import multiarray
ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "page01.py", line 3, in
from matplotlib import pyplot as plt
File "D:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 126, in
from . import cbook
File "D:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 34, in
import numpy as np
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in
from . import add_newdocs
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in
from .type_check import *
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in
import numpy.core.numeric as _nx
File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: 找不到指定的模块。
画图效果
解决办法将D:\ProgramData\Anaconda3\Library\bin加入环境变量: