2017-02-07 98 views
0

我正在尝试导入.py文件,它给出了错误。正在导入.py文件错误

import thinkplot 

和错误:

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

但是当我打开thinkplot.py文件,然后编写代码import thinkplot,它工作得很好。但没有打开文件,它不起作用。

在论坛上也有类似的问题,但他们都没有为我工作。我是Python的新手。我该如何解决这个问题?另外,我在ubuntu linux中使用python 2.7。谢谢...

+1

首先尝试编写'import thinkplot'(不含'.py')。 –

回答

0

请勿写.py,请写import thinkplot。请致电documentation

+0

对不起。我也试过没有.py。我也修正了它。但仍然给错误。 – ali

+0

你的文件位于何处?在同一个目录中? – Dmitry

+0

谢谢。他们不在同一个目录中。我修好了,现在可以使用了。 – ali