# -*-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. [UE4]Visual Studio的相关插件安装:UE4.natvis和UnrealVS Extension

    转自:http://aigo.iteye.com/blog/2281182 UE4.natvis 官方文档: https://docs.unrealengine.com/latest/INT/Prog ...

  2. Frequently Asked Questions

    转自:http://www.tornadoweb.org/en/stable/faq.html Frequently Asked Questions Why isn’t this example wi ...

  3. VFS文件系统结构分析

    VFS是Linux非常核心的一个概念,linux下的大部分操作都要用到VFS的相关功能.这里从使用者的角度,对VFS进行了简单说明.使用者不但需要知道Linux下有哪些文件操作的函数,还需要对VFS的 ...

  4. 2k8 32bit下载

    Windows Server 2008 32-bit Standard(标准版) Windows Server 2008 32-bit Enterprise(企业版) Windows Server 2 ...

  5. 关于THINKPHP5模型关联的初步理解

    初步理解的意思是,使用最常用的关联模型,然后可以正常运行 还是打个比方 文章表  和文章分类表 一个文章分类可以有多个文章  所以  文章分类模型和文章建立 hasMany的关联 而文章和文章分类表则 ...

  6. 《GPU高性能编程CUDA实战》附录四 其他头文件

    ▶ cpu_bitmap.h #ifndef __CPU_BITMAP_H__ #define __CPU_BITMAP_H__ #include "gl_helper.h" st ...

  7. Dell Latitude 3490 使用 UEFI+GPT 安装 Win7 x64

    转载请注明出处!转载请注明出处!转载请注明出处! 公司近期采购了一批笔记本,由于刚好赶上Dell升级换代,原来的3480升级到了3490. 由于部分同事用不惯Win10系统,再加上有些软件不兼容,于是 ...

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

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

  9. Java实现邮箱发送

  10. CentOS Tomcat启动 Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

    链接:http://blog.csdn.net/shangdiyisi/article/details/9477521 [bravoinfo@bravoinfo-hk-01 apache-tomcat ...