# -*-coding:gb2312-*-

 #Function:学习python的httplib模块

 import httplib

 conn = httplib.HTTPConnection("www.youku.com")
conn.request('get', '/')
print conn.getresponse().read() conn.close()

就这几行代码,出现以下错误提示:

> "C:\Python27\python.exe"  "E:\Python-Program\学习模块功能\httplib.py"
Traceback (most recent call last):
  File "E:\Python-Program\学习模块功能\httplib.py", line 5, in <module>
    import httplib
  File "E:\Python-Program\学习模块功能\httplib.py", line 7, in <module>
    conn = httplib.HTTPConnection("www.youku.com")
AttributeError: 'module' object has no attribute 'HTTPConnection'

原因:

(1)此处原因——"E:\Python-Program\学习模块功能\httplib.py"定义该模块的名称也为httplib.py

出现以上问题的可能原因:或者是python安装有问题,或者是另有一个httplib模块,它在模块搜索路径中的位置在系统内置的httplib模块之前,覆盖了系统内置的httplib模块。

注意:以后命名文件以及python程序内部的变量等,不要与关键词、方法、模块名等相冲突

修改:修改此处的名字为非httplib.py的名字,且需要删除之前生成的httplib.pyc模块

(2)还有一个可能原因:从网上查找资料发现,python本身没有安装openssl模块,也会报这个错误

httplib:AttributeError: 'module' object has no attribute 'HTTPConnection'的更多相关文章

  1. 【Python】【亲测好用】安装第三方包报错:AttributeError:'module' object has no attribute 'main'

    安装/卸载第三包可能出现如下问题及相应解决办法: 在pycharm编辑中,使用anconda2更新.卸载第三方包时,出现如下错误: AttributeError:'module' object has ...

  2. 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'

    利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...

  3. pytorch版本问题:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'

    用pytorch加载训练好的模型的时候遇到了如下的问题: AttributeError: 'module' object has no attribute '_rebuild_tensor_v2' 到 ...

  4. python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

    AttributeError: 'module' object has no attribute 'SSL_ST_INIT' 问题背景: 下载工具wydomain,安装依赖包以后,出现下图问题. 几经 ...

  5. python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'(转)

    原文地址:http://www.cnblogs.com/zhaijiahui/p/7344778.html AttributeError: 'module' object has no attribu ...

  6. 在运行create_list.sh时候报错:AttributeError: 'module' object has no attribute 'LabelMap'

    Traceback (most recent call last):File "/opt/xuben-project/caffe/data/VOC0712/../../scripts/cre ...

  7. python 脚本运行时报错: AttributeError: 'module' object has no attribute ***

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  8. pytorch报错:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'

    转载自: https://blog.csdn.net/qq_24305433/article/details/80844548 由于训练模型时使用的是新版本的pytorch,而加载时使用的是旧版本的p ...

  9. pycharm 安装第三方库报错:AttributeError: 'module' object has no attribute 'main'

    pip升级到 10.0.1 之后 老版的pycharm 使用pip安装第三方库的时候会报错,报错如上图所示: 其主要原因是 新版的 pip 更改了 部分api 将其中 pip.main() 改为 pi ...

随机推荐

  1. [转]Windows 注册自定义的协议

    [转自] http://blog.sina.com.cn/s/blog_86e4a51c01010nik.html 1.注册应用程序来处理自定义协议 你必须添加一个新的key以及相关的value到HK ...

  2. unity3d之Editor的Assembly-CSharp.dll文件路径

    在Editor中与自己project中使用的Mono与Managed文件夹路径区别: Editor中:在unity安装路径[AppDir]下: 自己project中:在project的路径下,由bui ...

  3. NLP-Progress记录NLP最新数据集、论文和代码: 助你紧跟NLP前沿

    Github https://github.com/sebastianruder/NLP-progress 官方网址 https://nlpprogress.com/ NLP-Progress 同时涵 ...

  4. Oracle 存储过程 延迟执行 DBMS_LOCK.SLEEP(60);

      --测试代码: declare -- Local variables here i integer; begin -- Test statements here dbms_output.put_l ...

  5. 单例模式(Singleton)

    单例模式  Singletonn Pattern Ensure a class has only one instance, and provide  a global point of access ...

  6. psc格式的文件是什么

    psc格式的文件是什么 是navicat 这个工具导出的数据文件 可以使用备份还原功能  提取sql

  7. OpenACC 《大规模并行处理器编程实战》教材讲解

    ▶ <大规模并行处理器编程实战>第15章,关于OpenACC 的部分,散点 ● OpenACC 中,主机存储器和设备存储器是分开处理的,程序员只要制定要传输的存储器对象即可,编译器会自动生 ...

  8. 25. oracle密码过期解决

    解决方法: 1.连接到oracle会自动提示修改数据库密码; 2.如果要设置为数据库密码不过期,可以直接修改: 查看:select * from dba_profiles where profile= ...

  9. JAVA 整合 SSM (Spring + SpringMVC + MyBatis)

    < 一 > POM 配置文件 ( 如果出现 JAR 包 引入错误, 请自行下载 ) <project xmlns="http://maven.apache.org/POM/ ...

  10. Spring boot 执行jar文件 方式

    项目jar包名wxo.jar 清理,打包,跳过测试(不测试) mvn clean package -Dmaven.test.skip=true 后台执行(默认环境) nohup java -jar w ...