# -*-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. oracle查看处理过程

    通过函数可以查看数据库的执行过程

  2. Hessian与Webservice的区别

    Hessian:hessian是一个轻量级的remoting onhttp工具,使用简单的方法提供了RMI的功能,相比WebService,Hessian更简单.快捷. 采用的是二进制RPC协议,因为 ...

  3. 手贱,写个call玩玩.

    今天在睡觉醒时,突然感觉对call和apply有了点理解,但是又不好表达出来.就随便写几个例子. function say() { return this.role; } function Fathe ...

  4. storm项目优化

    实现监控脚本监控topology运行状态

  5. noip 2011 选择客栈

    题目描述 丽江河边有n 家很有特色的客栈,客栈按照其位置顺序从 1 到n 编号.每家客栈都按照某一种色调进行装饰(总共 k 种,用整数 0 ~ k-1 表示),且每家客栈都设有一家咖啡店,每家咖啡店均 ...

  6. jmeter测试20个QPS下的响应时间-设置QPS限制

    添加--->定时器--->Constant Throughput Timer Constant Throughput Timer 的主要属性介绍: 名称:定时器的名称 Target thr ...

  7. 13.从url 输入网址到最终页面渲染完成

    从url 输入网址到最终页面渲染完成,发生了什么? 1.DNS解析:将域名地址解析为IP地址 先读取: -浏览器DNS缓存 -系统DNS缓存 -路由器DNS缓存 -网络运营商DNS缓存 -递归搜索:b ...

  8. Nginx相关笔记

    相关参考: 编译安装测试nginx            https://www.cnblogs.com/jimisun/p/8057156.html

  9. 在 html中怎么获取中的参数

    参考:https://blog.csdn.net/xqhys/article/details/68486215 eg: window.location.href="/user/update? ...

  10. 8.tomcat认证访问

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 接上例:namespce的作用除了在前面提到的避免协同开发名字冲突外,还为认 ...