尝试使用matplotlib,但出现错误

时间:2019-11-06 23:03:04

标签: python python-3.x matplotlib

我正在使用Python 3.7.5 + PyCharm 2018 Edition 下面显示了启动时控制台中显示的内容:

Traceback (most recent call last):
File "C:/Users/User/Desktop/Проект ДО ЧЕТВЕРГА!/тест либы yandex.translate.py", line 3, in <module>
      import matplotlib
File "C:\Python\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
      from . import cbook, rcsetup
File "C:\Python\lib\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
      import numpy as np
File "C:\Python\lib\site-packages\numpy\__init__.py", line 140, in <module>
      from . import _distributor_init
File "C:\Python\lib\site-packages\numpy\_distributor_init.py", line 26, in <module>
      WinDLL(os.path.abspath(filename))
File "C:\Python\lib\ctypes\__init__.py", line 364, in __init__
      self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

Process finished with exit code 1

我要运行的代码:

datelist =  ['2014-05-06', '2014-05-07', '2014-05-08', '2014-05-09', '2014-05-10',    '2014-05-11', '2014-05-12', '2014-05-13']

import matplotlib
from matplotlib import pyplot
from matplotlib import dates
import datetime

converted_dates = list(map(datetime.datetime.strptime, datelist, len(datelist)*['%Y-%m-%d']))
x_axis = converted_dates
formatter = dates.DateFormatter('%Y-%m-%d')


y_axis = range(0,8)
pyplot.plot( x_axis, y_axis, '-' )
ax = pyplot.gcf().axes[0]
ax.xaxis.set_major_formatter(formatter)
pyplot.gcf().autofmt_xdate(rotation=25)
pyplot.show()

如果您能帮助我找到错误并帮助纠正错误,将非常高兴。

1 个答案:

答案 0 :(得分:-1)

我已经安装了这些库的非正式版本。错误消失了