在使用matplotlib.pyplot作图时,程序运行出现错误:
[WinError 2] 系统找不到指定的文件
Figure size 432x288 with 1 Axes>
并且不显示图像
使用的代码如下:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.show()
运行结果如下:
```FileNotFoundError Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\IPython\core\formatters.py in call(self, obj)
339 pass
340 else:
--> 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)
D:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in (fig)
239
240 if 'png' in formats:
--> 241 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
242 if 'retina' in formats or 'png2x' in formats:
243 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
D:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
123
124 bytes_io = BytesIO()
--> 125 fig.canvas.print_figure(bytes_io, **kw)
126 data = bytes_io.getvalue()
127 if fmt == 'svg':
D:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2210 orientation=orientation,
2211 dryrun=True,
-> 2212 **kwargs)
2213 renderer = self.figure._cachedRenderer
2214 bbox_inches = self.figure.get_tightbbox(renderer)
D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self)
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
D:\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1491
1492 mimage._draw_list_compositing_images(
-> 1493 renderer, self, artists, self.suppressComposite)
1494
1495 renderer.close_group('figure')
D:\Anaconda3\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
139 if not_composite or not has_images:
140 for a in artists:
--> 141 a.draw(renderer)
142 else:
143 # Composite any adjacent images together
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
D:\Anaconda3\lib\site-packages\matplotlib\axes_base.py in draw(self, renderer, inframe)
D:\Anaconda3\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
139 if not_composite or not has_images:
140 for a in artists:
--> 141 a.draw(renderer)
142 else:
143 # Composite any adjacent images together
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
D:\Anaconda3\lib\site-packages\matplotlib\axis.py in draw(self, renderer, *args, **kwargs)
D:\Anaconda3\lib\site-packages\matplotlib\axis.py in _get_tick_bboxes(self, ticks, renderer)
D:\Anaconda3\lib\site-packages\matplotlib\text.py in get_window_extent(self, renderer, dpi)
920 raise RuntimeError('Cannot get window extent w/o renderer')
921
--> 922 bbox, info, descent = self._get_layout(self._renderer)
923 x, y = self.get_unitless_position()
924 x, y = self.get_transform().transform_point((x, y))
D:\Anaconda3\lib\site-packages\matplotlib\text.py in _get_layout(self, renderer)
307 w, h, d = renderer.get_text_width_height_descent(clean_line,
308 self._fontproperties,
--> 309 ismath=ismath)
310 else:
311 w, h, d = 0, 0, 0
D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
D:\Anaconda3\lib\site-packages\matplotlib\texmanager.py in get_text_width_height_descent(self, tex, fontsize, renderer)
499 else:
500 # use dviread. It sometimes returns a wrong descent.
--> 501 dvifile = self.make_dvi(tex, fontsize)
502 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
503 page = next(iter(dvi))
D:\Anaconda3\lib\site-packages\matplotlib\texmanager.py in make_dvi(self, tex, fontsize)
363 self._run_checked_subprocess(
364 ["latex", "-interaction=nonstopmode", "--halt-on-error",
--> 365 texfile], tex)
366 for fname in glob.glob(basefile + '*'):
367 if not fname.endswith(('dvi', 'tex')):
D:\Anaconda3\lib\site-packages\matplotlib\texmanager.py in _run_checked_subprocess(self, command, tex)
333 report = subprocess.check_output(command,
334 cwd=self.texcache,
--> 335 stderr=subprocess.STDOUT)
336 except subprocess.CalledProcessError as exc:
337 raise RuntimeError(
D:\Anaconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
374
375 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 376 **kwargs).stdout
377
378
D:\Anaconda3\lib\subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
451 kwargs['stderr'] = PIPE
452
--> 453 with Popen(*popenargs, **kwargs) as process:
454 try:
455 stdout, stderr = process.communicate(input, timeout=timeout)
D:\Anaconda3\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
754 c2pread, c2pwrite,
755 errread, errwrite,
--> 756 restore_signals, start_new_session)
757 except:
758 # Cleanup if the child failed starting.
D:\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1153 env,
1154 os.fspath(cwd) if cwd is not None else None,
-> 1155 startupinfo)
1156 finally:
1157 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
```
已安装的库如下:
Package Version
-cipy 1.1.0
-illow 5.2.0
alabaster 0.7.11
amply 0.1.4
anaconda-client 1.7.2
anaconda-navigator 1.9.2
anaconda-project 0.8.2
appdirs 1.4.3
asn1crypto 0.24.0
astroid 2.0.4
astropy 3.0.4
atomicwrites 1.2.1
attrs 18.2.0
Automat 0.7.0
Babel 2.6.0
backcall 0.1.0
backports.shutil-get-terminal-size 1.0.0
beautifulsoup4 4.6.3
bitarray 0.8.3
bkcharts 0.2
blaze 0.11.3
bleach 2.1.4
bokeh 0.13.0
boto 2.49.0
Bottleneck 1.2.1
certifi 2020.6.20
cffi 1.11.5
chardet 3.0.4
click 6.7
cloudpickle 0.5.5
clyent 1.2.2
colorama 0.3.9
comtypes 1.1.7
conda 4.5.11
conda-build 3.15.1
constantly 15.1.0
contextlib2 0.5.5
cryptography 2.3.1
cvxopt 1.2.5.post1
cvxpy 1.1.5
cycler 0.10.0
Cython 0.28.5
cytoolz 0.9.0.1
dask 0.19.1
data 0.4
datashape 0.5.4
decorator 4.3.0
defusedxml 0.5.0
distributed 1.23.1
docutils 0.14
ecos 2.0.7.post1
entrypoints 0.2.3
et-xmlfile 1.0.1
fastcache 1.0.2
filelock 3.0.8
Flask 1.0.2
Flask-Cors 3.0.6
funcsigs 1.0.2
future 0.18.2
gevent 1.3.6
glob2 0.6
greenlet 0.4.15
h5py 2.8.0
heapdict 1.0.0
html5lib 1.0.1
hyperlink 18.0.0
idna 2.7
imageio 2.4.1
imagesize 1.1.0
incremental 17.5.0
ipykernel 4.10.0
ipython 6.5.0
ipython-genutils 0.2.0
ipywidgets 7.4.1
isort 4.3.4
itsdangerous 0.24
jdcal 1.4
jedi 0.12.1
Jinja2 2.10
jsonschema 2.6.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
jupyterlab 0.34.9
jupyterlab-launcher 0.13.1
keyring 13.2.1
kiwisolver 1.0.1
latex 0.7.0
lazy-object-proxy 1.3.1
llvmlite 0.24.0
locket 0.2.0
lxml 4.2.5
MarkupSafe 1.0
matplotlib 3.3.2
mccabe 0.6.1
menuinst 1.4.14
mistune 0.8.3
mkl-fft 1.0.4
mkl-random 1.0.1
more-itertools 4.3.0
mpmath 1.0.0
msgpack 0.5.6
multipledispatch 0.6.0
navigator-updater 0.2.1
nbconvert 5.4.0
nbformat 4.4.0
networkx 2.1
nltk 3.3
nose 1.3.7
notebook 5.6.0
numba 0.39.0
numexpr 2.6.8
numpy 1.17.4+mkl
numpydoc 0.8.0
odo 0.5.1
olefile 0.46
openpyxl 2.5.6
osqp 0.6.1
packaging 17.1
pandas 0.23.4
pandocfilters 1.4.2
parso 0.3.1
partd 0.3.8
path.py 11.1.0
pathlib2 2.3.2
patsy 0.5.0
pep8 1.7.1
pickleshare 0.7.4
Pillow 8.0.0
pip 20.2.3
pkginfo 1.4.2
pluggy 0.7.1
ply 3.11
prometheus-client 0.3.1
prompt-toolkit 1.0.15
psutil 5.4.7
PuLP 2.3
py 1.6.0
pyasn1 0.4.4
pyasn1-modules 0.2.2
pycodestyle 2.4.0
pycosat 0.6.3
pycparser 2.18
pycrypto 2.6.1
pycurl 7.43.0.2
pyflakes 2.0.0
Pygments 2.2.0
PyHamcrest 2.0.2
pylint 2.1.1
pyodbc 4.0.24
pyOpenSSL 18.0.0
pyparsing 2.2.0
PySocks 1.6.8
pytest 3.8.0
pytest-arraydiff 0.2
pytest-astropy 0.4.0
pytest-doctestplus 0.1.3
pytest-openfiles 0.3.0
pytest-remotedata 0.3.0
python-dateutil 2.7.3
pytz 2018.5
PyWavelets 1.0.0
pywin32 223
pywinpty 0.5.4
PyYAML 3.13
pyzmq 17.1.2
QtAwesome 0.4.4
qtconsole 4.4.1
QtPy 1.5.0
requests 2.19.1
rope 0.11.0
ruamel-yaml 0.15.46
scikit-image 0.14.0
scikit-learn 0.19.2
scipy 1.5.2
scs 2.1.2
seaborn 0.9.0
Send2Trash 1.5.0
service-identity 17.0.0
setuptools 40.2.0
shutilwhich 1.1.0
simplegeneric 0.8.1
singledispatch 3.4.0.3
six 1.11.0
snowballstemmer 1.2.1
sortedcollections 1.0.1
sortedcontainers 2.0.5
Sphinx 1.7.9
sphinxcontrib-websupport 1.1.0
spyder 3.3.1
spyder-kernels 0.2.6
SQLAlchemy 1.2.11
statsmodels 0.9.0
sympy 1.1.1
tables 3.4.4
tblib 1.3.2
tempdir 0.7.1
terminado 0.8.1
testpath 0.3.1
toolz 0.9.0
tornado 5.1
tqdm 4.26.0
traitlets 4.3.2
Twisted 18.7.0
unicodecsv 0.14.1
urllib3 1.23
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.14.1
wheel 0.31.1
widgetsnbextension 3.4.1
win-inet-pton 1.0.1
win-unicode-console 0.5
wincertstore 0.2
wrapt 1.10.11
xlrd 1.1.0
XlsxWriter 1.1.0
xlwings 0.11.8
xlwt 1.3.0
zict 0.1.3
zope.interface 4.5.0
请问一下应该如何解决?(CSDN上找过很多方法都没能解决)
https://blog.csdn.net/u011394059/article/details/78131352
问题解决了吗?