Python安装错误没有为pyplot找到匹配的分发

lee*_*fry 11 python matplotlib

我正在尝试运行此程序

import matplotlib.pyplot as plt
import numpy

plt.plot([1, 2, 3],[5, 7, 4])
plt.show()
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:ImportError:没有名为pyplot的模块

我已经在Windows 8 64位上安装了matplotlib,使用来自bash的pip命令安装了Python 2.7,我也更新了它,结果收到了这条消息:

Aneta@AKZ-5K-Computer:~$ C:/Python27/Scripts/pip install --upgrade matplotlib
Requirement already up-to-date: matplotlib in c:\python27\lib\site-packages
Requirement already up-to-date: pyparsing>=1.5.6 in c:\python27\lib\site-packages\pyparsing-2.0.3-py2.7-win32.egg (from matplotlib)
Requirement already up-to-date: numpy>=1.6 in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: pytz in c:\python27\lib\site-packages\pytz-2015.6-py2.7.egg (from matplotlib)
Requirement already up-to-date: python-dateutil in c:\python27\lib\site-packages\python_dateutil-2.4.2-py2.7.egg (from matplotlib)
Requirement already up-to-date: six>=1.4 in c:\python27\lib\site-packages\six-1.10.0-py2.7.egg (from matplotlib)
Run Code Online (Sandbox Code Playgroud)

当我尝试安装pyplot时,我得到了这个按摩:

Aneta@AKZ-5K-Computer:~$ C:/Python27/Scripts/pip install pyplot
Collecting pyplot
  Could not find a version that satisfies the requirement pyplot (from versions: )
No matching distribution found for pyplot
Run Code Online (Sandbox Code Playgroud)

如果有人知道如何安装pyplot以及为什么我的发行版不匹配,我感谢您的帮助.

pym*_*man 7

尝试从这里重新安装matplotlib .如果你在64位计算机上也没关系(我也是).重要的是你安装了哪个版本的Python?如果您安装了32位(推荐它更容易处理),那么您仍然安装32位版本的模块.

我链接的网站显示了matplotlib的必备模块,因此请确保您已安装这些模块.


小智 6

或者您可以尝试做 pip install matplotlib。然后导入matplotlib.pyplot以获取pyplot数据。matplotlib是一个内部带有pyplot的模块,因此您可以轻松访问pyplot。

  • 这是要点:`pip install matplotlib`,以便您可以`import matplotlib.pyplot as plt`或`import pylab` (2认同)

小智 6

如果你试试

pip install matplotlib
Run Code Online (Sandbox Code Playgroud)

它失败了,试试

pip install --upgrade matplotlib
Run Code Online (Sandbox Code Playgroud)

您可能已经预先安装了该软件包。