我想运行一个 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/