Cloud
Cloud

Reputation: 125

ImportError: No module named pyplot

I'm using Ubuntu 14.04 LTS.

and I installed python-matplotlib using apt-get command.

When using this code in python command-line,

#!/bin/python
# -*- coding: utf8 -*-

# test.py

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()

this works.

but when using .py file, this error appears.

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/home/cloud/Dropbox/dc/hw02/matplotlib.py", line 6, in <module>
ImportError: No module named pyplot

Please help..

Upvotes: 0

Views: 1566

Answers (1)

Indradhanush Gupta
Indradhanush Gupta

Reputation: 4237

As evident from the traceback, you have named your file matplotlib.py. Thus, python is trying to do a local import. Rename your file to something other than matplotlib.py.

Upvotes: 3

Related Questions