Python安装错误:找不到pyplot的匹配发行版。

14

我正在尝试运行这个程序

import matplotlib.pyplot as plt
import numpy

plt.plot([1, 2, 3],[5, 7, 4])
plt.show()

我收到一个错误信息: ImportError: No module named pyplot

我在Windows 8 64位系统上使用pip命令从bash安装了matplotlib,并进行了更新,但仍然无法解决问题。

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)

当我尝试安装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

如果有人知道如何安装pyplot以及为什么我的发行版不匹配,我将非常感激你的帮助。


我从一个wheel文件中安装了matplotlib,因为在Windows上我从pip安装64位版本从来没有成功过。所以尝试下载.wheel文件并从中安装。 - BlivetWidget
3个回答

9

请尝试从这里重新安装matplotlib。如果你的电脑是64位的,也没有关系。重要的是你安装了哪个版本的Python?如果你安装了32位(因为它比较容易处理),那么你仍然需要安装32位版本的模块。

我给你提供的网站显示了matplotlib的先决条件模块,请确保你已经安装了它们。


很棒的资源发布了。 - Anekdotin

9

您可以尝试执行 pip install matplotlib 命令安装 matplotlib。然后使用 import matplotlib.pyplot 导入 pyplot 数据。matplotlib 是一个包含 pyplot 的模块,因此您可以轻松访问 pyplot。


2
这是主要的要点:pip install matplotlib,这样你就可以 import matplotlib.pyplot as plt 或者 import pylab - nealmcb

9

如果您尝试

pip install matplotlib

如果它失败了,尝试

pip install --upgrade matplotlib

你可能已经预装了这个软件包。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接