简体   繁体   English

无法从同一目录(版本2.2)导入python文件

[英]Failed to import python file from the same directory (version 2.2)


I have the following python files: 我有以下python文件:
help_functions.py help_functions.py
check.py check.py
I'm trying to import help_functions file from check file (both files in the same directory) with the following command: 我正在尝试使用以下命令从检查文件(两个文件都在同一目录中)导入help_functions文件:

from help_functions import Utils

after running it from cmd with WLST which has Python 2.2 interpreter I get the following error: 使用具有Python 2.2解释器的WLST从cmd运行它后,出现以下错误:
ImportError:no module named help_functions

any idea what should I do to make it recognize the help_functions file? 知道该怎么做才能使其识别help_functions文件吗?

Short answer: add the scripts containing folder (full path, not relative) to your PYTHONPATH environment variable. 简短答案:将包含文件夹的脚本(完整路径,不是相对路径)添加到PYTHONPATH环境变量中。

Long answer: your scope is not what you think it is. 长答案:你的范围不是你想的那样。 See this answer for more details: ImportError: No module named... (basics?) 请参阅此答案以获取更多详细信息: ImportError:没有名为...的模块(基本?)

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

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