ali ali - 1 year ago 73
Python Question

importing .py file error

I am trying to import .py file and it gives the error.

import thinkplot


And the error :


Traceback (most recent call last):
File "", line 1, in
import thinkplot
ImportError: No module named thinkplotTraceback (most recent call last):
File "", line 1, in
import thinkplot
ImportError: No module named thinkplot


But when I open
thinkplot.py
file and then writing the code
import thinkplot
, it works well. But without opening the file, it doesn't work.

There are similar questions in the forum but none of them work for me. I am new to Python. How can I fix the problem ? Also, I am using python 2.7 in a ubuntu linux. Thank you...

Answer Source

Do not write .py, write import thinkplot. To get more information read documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download