有时候在运行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的引用错误。切记 要好好的阅读文档!!!