Python没有名为numpy的模块

标签 python ubuntu numpy

我想运行一个 python 示例:

#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt

x=[2,3,4,5,7,9,13,15,17]
plt.plot(x)
plt.ylabel('Sunlight')
plt.xlabel('Time')
plt.show()

当我尝试运行时: python plot.py 在我的 Ubuntu 16.04LTS 终端中,我得到以下输出:ImportError: No Module named 'numpy'。我通过运行以下命令安装了 numpy: sudo apt-get install python3-numpy .我正在使用 Python 3.5。如何制作 Ubuntu/Python 以导入 numpy 模块?

最佳答案

您必须执行 python3 plot.py .

或者如果你想运行 python (即python2),必须安装python-numpy .

请注意,您也可以直接执行脚本:

$ chmod +x plot.py
$ ./ploy.py

使用 python3将第一行更改为
#!/usr/bin/python3

关于Python没有名为numpy的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37216226/

相关文章:

python - 将概率与 scikit-learn 中的标签联系起来

google-chrome - Protractor woant 运行我的脚本

python - NumPy 数据类型不理解

python - 在Python中将矩阵数据转储到文本文件时插入行和列标签

python - 将OpenCV中的比较运算符转换为Python

postgresql - 如何将数据从 Windows 上的 postgres 移动到 Linux (Ubuntu) 上的 postgres

QT Systray 图标出现在 Ubuntu 上的启动器旁边而不是面板上

python - 减少代码重复类设计

python - Pandas 系列无法获得索引

python - 决策树 split