简体   繁体   English

Python:使用Wing IDE导入模块

[英]Python: Import Module with Wing IDE

I am new to Python and I have trouble to import modules with Wing IDE/Python 2.7/Mac OS 我是Python的新手,我很难用Wing IDE / Python 2.7 / Mac OS导入模块

I have read: Import module from other directory in Wing Ide 我读过: 从Wing Ide中的其他目录导入模块

and: http://docs.python.org/2/tutorial/modules.html 和: http//docs.python.org/2/tutorial/modules.html

but still I don't get it. 但我仍然没有得到它。

If, as presented in the second link, I create a fibo.py script and save it in my Python Path then when I try to import it, I have the following error: 如果,如第二个链接中所示,我创建一个fibo.py脚本并将其保存在我的Python路径中然后当我尝试导入它时,我有以下错误:

import fibo
Traceback (most recent call last):
File "<string>", line 1, in <fragment>
ImportError: No module named fibo

although fibo is available for auto-completion when I type 虽然当我输入时,fibo可用于自动完成

import 

What did I miss? 我错过了什么? Thanks for your answers 谢谢你的回答

That error indicates that the module is not found on the path, so either it's in the wrong place or the path is not what you think it is. 该错误表示在路径上找不到该模块,因此它位于错误的位置或路径不是您认为的那样。 You can look at sys.path (after 'import sys') to see the path. 您可以查看sys.path(在'import sys'之后)以查看路径。

I'm not certain why Wing is offering auto-completion there. 我不确定为什么Wing会在那里提供自动完成功能。 One possibility is that you've modified your Python Path in Project Properties (or Configure Python dialog in Wing 101) and have not yet restarted the Python Shell from its Options menu. 一种可能性是您已在Project Properties(或Wing 101中的Configure Python对话框)中修改了Python Path,并且尚未从其Options菜单重新启动Python Shell。

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

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