# -*-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. Shell 定时发送邮件检查网站脚本/邮件正文

    #!/bin/bash ############################################################## # File Name: check_http.s ...

  2. ajax异步、同步问题,KindEditor ajax提交内容,ajax提交form表单 解决按两次的问题

    版权声明:本文为博主原创文章,未经博主允许不得转载. 如果ajax不采用异步,整个js代码在服务器返回结果前都将阻塞,alert方法除外 lookUp('lookUp','',100,300,3); ...

  3. 在线学习和在线凸优化(online learning and online convex optimization)—FTRL算法6

  4. C# webbrowser实现百度知道团队邀请助手!

    [百度知道团队邀请助手] 是您快速提高百度知道团队成员数和团队排名的利器! 主要功能: 1.运用C#自带的webbrowser自动登录百度: 2.自动采集请在C#.Net分类排名下的所有用户,邀请这些 ...

  5. Phoenix 安装完的几个简单使用

    Phoenix 安装完之后的一些简单使用: 本屌丝的运行环境是3节点集群,先启动hadoop,每个节点分别启动zookeeper,启动hbase(具体怎么启动这里就不多说了) 进入 phoenix的b ...

  6. XPath 常用语法札记

    * 不包含属性的元素 例如不包含属性的span: span[not(@*)] * 文本包含某部分的元素 例如文本包含Rank的元素: *[contains(text(),'Rank')] * 选择匹配 ...

  7. 代码:cookie(一个广告展示例子)

    这个小例子的要求是: 用户第一次进入,显示大图,2秒后大图动画关闭,再把小图动画展开: 用户再次进入后,只显示静态小图. 做法: 定义一个容器 .img201512ad,宽高写死:1190x70.—— ...

  8. 二维数组 cudaMallocPitch() 和三维数组 cudaMalloc3D() 的使用

    ▶ 使用函数 cudaMallocPitch() 和配套的函数 cudaMemcpy2D() 来使用二维数组.C 中二维数组内存分配是转化为一维数组,连贯紧凑,每次访问数组中的元素都必须从数组首元素开 ...

  9. TortoiseGit上传项目到GitHub

    1. 简介 gitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格式进行托管,故名gitHub. 2. 准备 2.1  安装git:https://git-scm.c ...

  10. git 提交文件到gitee

    1.新建文件夹   打开gitbash  初始化仓库 git.init 2.把要提交的文件copy到文件夹 3.git add. 4.git remote add master(分支)  远程仓库 5 ...