【问题标题】:No module named bumpy [duplicate]没有名为bumpy的模块[重复]
【发布时间】:2014-04-21 00:54:43
【问题描述】:

我是新的 mac 用户和 python 的新手。

我只是安装了 python 2.7 和 matplotlib 并尝试运行这个演示代码:

"""
Simple demo with multiple subplots.
"""
import numpy as np
import matplotlib.pyplot as plt


x1 = np.linspace(0.0, 5.0)
x2 = np.linspace(0.0, 2.0)

y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2)

plt.subplot(2, 1, 1)
plt.plot(x1, y1, 'yo-')
plt.title('A tale of 2 subplots')
plt.ylabel('Damped oscillation')

plt.subplot(2, 1, 2)
plt.plot(x2, y2, 'r.-')
plt.xlabel('time (s)')
plt.ylabel('Undamped')

plt.show()

当我单击运行 -> 运行模块时,我收到此错误:

Traceback (most recent call last):
  File "/Users/mehmetalinadigulec/Desktop/subplot_demo.py", line 4, in <module>
    import numpy as np
ImportError: No module named numpy

我搜索了几个小时,但无法修复它。

我编辑我的 ~/.bash_profile

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PYTHONPATH="/Library/Python/2.7/site-packages:${PYTHONPATH}"
export PYTHONPATH

结果

echo $PYHTONPATH
/Library/Python/2.7/site-packages:

【问题讨论】:

  • numpy 不是 Python 标准库的一部分。你安装正确了吗?
  • 我,呃...假设 bumpy 是您标题中的错字?
  • 请在询问之前用 Google 搜索您写的 title
  • penandpants.com/2012/02/24/install-python 我使用此指令安装 python 和 matlablib。和 /usr/local/bin/idle 打开 python idle 比打开 .py 文件并运行。它有效..

标签: python macos numpy matplotlib


【解决方案1】:

简单的答案似乎是通过http://www.scipy.org/install.html 安装numpy

【讨论】:

    猜你喜欢
    • 2020-12-22
    • 2017-01-07
    • 2019-07-23
    • 2020-04-10
    • 2020-03-27
    • 1970-01-01
    • 2020-12-29
    • 2015-06-21
    • 2014-07-28
    相关资源
    最近更新 更多