Python模块导入问题 [英] Python Module Importing Issues

查看:139
本文介绍了Python模块导入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行Windows 7,我可以导入内置的模块,但是当我保存我自己的脚本并尝试在IDLE中导入时,我收到一个错误,表示该模块不存在。

I run Windows 7, and I can import built-in modules, but when I save my own script and try to import it in IDLE, I get an error saying that the module doesn't exist.

我使用Python文本编辑器,通过点击文件和新窗口从Python Shell中找到。我将其保存为我在Python目录下创建的Module文件夹中的.py文件。但是,每当我在IDLE中输入import module_name时,它表示该模块不存在。

I use the Python text editor found by clicking "File" and "New Window" from the Python Shell. I save it as a .py file within a Module folder I created within the Python directory. However, whenever i type import module_name in IDLE, it says that the module doesn't exist.

我做错了什么或不做?我尝试导入module_name,import module_name.py,python module_name,python module_name.py

What am I doing wrong, or not doing? I've tried import module_name, import module_name.py, python module_name, python module_name.py

推荐答案

Python使用PYTHONPATH环境变量定义导入模块时应查看的文件夹列表。很可能您的文件夹不是PYTHONPATH

Python uses PYTHONPATH environment variable to define a list of folders which should be looked at when importing modules. Most likely your folder is not PYTHONPATH

这篇关于Python模块导入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆