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的引用错误。切记 要好好的阅读文档!!!
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的引用错误。切记 要好好的阅读文档!!!
相关文章推荐
- python 文件读写时用open还是codecs.open
- python 正则表达式使用
- 模拟登录-知乎
- python操作数据库 - SQLAlchemy
- Python 爬虫中遇到的反爬虫问题
- Python进阶06 循环对象
- python基础练习之简单用户消费卡管理(非完整版)
- Python进阶05 循环设计
- python之GUI编程(一)
- windows下面安装Python和pip终极教程
- 我对python线程池的理解
- Python爬虫
- 【Python基础】Python面向对象 - 9 - 类属性,实例属性
- Python之sys模块小探
- Python类的专用方法
- Python:函数参数传递:传值?引用?
- Python 冒泡排序
- Head First Python 第二章 函数模块&第三章 文件与异常&第四章 持久存储&第五章 处理数据
- python数据挖掘
- python教程