0

I want to run a python example:

#!/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()

When I' try to run: python plot.py in my Ubuntu 16.04LTS terminal, I get this output: ImportError: No Module named 'numpy'. I have installed numpy by running this command: sudo apt-get install python3-numpy. I'm using Python 3.5. How can I make Ubuntu/Python in order to import numpy module?

1 Answer 1

2

You must exec python3 plot.py.

Or if you want to run python (that is, python2), you must install python-numpy.

Note that you can also exec you script direct:

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

to use python3 change the first line to

#!/usr/bin/python3
Sign up to request clarification or add additional context in comments.

5 Comments

Already tried to run: python3 plot.py also python3.5 plot.py and same problem.
That's weird. Are you sure that python3-numpy is installed? (check with dpkg -s python3-numpy). Have you noted that you example doesn't need numpy? Have you tried with python2?
Yes, numpy is installed. Package: python3-numpy, Status: install ok installed. I'm try to run example from this [link] (pythonprogramminglanguage.com/line-charts)
No positive results with python2. I have both python2.7 and python3.5 installed. Could be some compatibility issues!?
Solved. Used to run: sudo pip3 install numpy. But now is another problem :), can't install matlibplot. I get some error but I will find a way to solve it. Thanks @malbarbo for your support!!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.