您的位置:首页 > 编程语言 > Python开发

Python ImportError: cannot import name *

2015-09-13 23:23 986 查看
有时候在运行python脚本,提示导入name错误,比如

ImportError: cannot import name timegm

下面看一下文档

Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the current directory), PYTHONPATH and the installation- dependent default. This allows Python programs
that know what they’re doing to modify or replace the module search path. Note that because the directory containing the script being run is on the search path, it is important that the script not have the same name as a standard module, or Python will attempt
to load the script as a module when that module is imported.

此时可以去脚本目录下检查一下有没有和python自带模块名称一致的.py文件,这会导致python的引用错误。切记 要好好的阅读文档!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: