简体   繁体   English

导入.py文件错误

[英]importing .py file error

I am trying to import .py file and it gives the error. 我正在尝试导入.py文件,它给出了错误。

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 追溯(最近一次调用,最后一次):导入thinkplot ImportError中的文件“”,第1行:无模块,名称为thinkplotTraceback(最新一次调用,最后一次):导入thinkplot,错误,未导入模块,“第1行”,导入模块

But when I open thinkplot.py file and then writing the code import thinkplot , it works well. 但是,当我打开thinkplot.py文件,然后编写代码import thinkplot ,它运行良好。 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. 我是Python的新手。 How can I fix the problem ? 我该如何解决该问题? Also, I am using python 2.7 in a ubuntu linux. 另外,我在ubuntu linux中使用python 2.7。 Thank you... 谢谢...

Do not write .py , write import thinkplot . 不要写.py ,写import thinkplot To get more information read documentation . 要获取更多信息,请阅读文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM