httplib:AttributeError: 'module' object has no attribute 'HTTPConnection'
# -*-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'的更多相关文章
- 【Python】【亲测好用】安装第三方包报错:AttributeError:'module' object has no attribute 'main'
安装/卸载第三包可能出现如下问题及相应解决办法: 在pycharm编辑中,使用anconda2更新.卸载第三方包时,出现如下错误: AttributeError:'module' object has ...
- 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'
利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...
- pytorch版本问题:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
用pytorch加载训练好的模型的时候遇到了如下的问题: AttributeError: 'module' object has no attribute '_rebuild_tensor_v2' 到 ...
- python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
AttributeError: 'module' object has no attribute 'SSL_ST_INIT' 问题背景: 下载工具wydomain,安装依赖包以后,出现下图问题. 几经 ...
- python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'(转)
原文地址:http://www.cnblogs.com/zhaijiahui/p/7344778.html AttributeError: 'module' object has no attribu ...
- 在运行create_list.sh时候报错:AttributeError: 'module' object has no attribute 'LabelMap'
Traceback (most recent call last):File "/opt/xuben-project/caffe/data/VOC0712/../../scripts/cre ...
- python 脚本运行时报错: AttributeError: 'module' object has no attribute ***
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- pytorch报错:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
转载自: https://blog.csdn.net/qq_24305433/article/details/80844548 由于训练模型时使用的是新版本的pytorch,而加载时使用的是旧版本的p ...
- pycharm 安装第三方库报错:AttributeError: 'module' object has no attribute 'main'
pip升级到 10.0.1 之后 老版的pycharm 使用pip安装第三方库的时候会报错,报错如上图所示: 其主要原因是 新版的 pip 更改了 部分api 将其中 pip.main() 改为 pi ...
随机推荐
- html5 progress样式修改
CSS代码: .deal progress { -webkit-appearance: none; } .deal ::-webkit-progress-inner-element { } .deal ...
- R语言中的遗传算法详细解析
前言 人类总是在生活中摸索规律,把规律总结为经验,再把经验传给后人,让后人发现更多的规规律,每一次知识的传递都是一次进化的过程,最终会形成了人类的智慧.自然界规律,让人类适者生存地活了下来,聪明的科学 ...
- ECCV 2018 | UBC&腾讯AI Lab提出首个模块化GAN架构,搞定任意图像PS组合
通常的图像转换模型(如 StarGAN.CycleGAN.IcGAN)无法实现同时训练,不同的转换配对也不能组合.在本文中,英属哥伦比亚大学(UBC)与腾讯 AI Lab 共同提出了一种新型的模块化多 ...
- C#中 ThreadStart和ParameterizedThreadStart区别
最主要区别: 1.Thread 是启动一个线程,但是没有参数. 2.ParameterThreadStart 线程可以接受一个输入参数 ThreadStart: ThreadStart这个委托定义为 ...
- django中使用Form组件
内容: 1.Form组件介绍 2.Form组件常用字段 3.Form组件校验功能 4.Form组件内置正则校验 参考:https://www.cnblogs.com/liwenzhou/p/87478 ...
- django的小操作,查询效率up, 引用art-template模板+djangorestframework
Part1: 提高查询效率newses = News.objects.select_related('category', 'author').get(id=1) # category和author字 ...
- 练手THINKPHP5过程和bootstrap3.3.7
1 在GIT上下载了最新版的源码,同时安装composer 用composer更新 git地址https://github.com/top-think/think 2 搭建本地开发环境,开启url重写 ...
- myBatis连接MySQL报异常:No operations allowed after connection closed.Connection was implicitly closed
网站运行一个晚上,早上来上班,发现报错: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTra ...
- 9 个Java 异常处理的规则
在 Java 中,异常处理是个很麻烦的事情.初学者觉得它很难理解,甚至是经验丰富的开发者也要花费很长时间决定异常是要处理掉和抛出. 所以很多开发团队约定一些原则处理异常.如果你是一个团队的新成员,你可 ...
- 机器学习入门-混淆矩阵-准确度-召回率-F1score 1.itertools.product 2. confusion_matrix(test_y, pred_y)
1. itertools.product 进行数据的多种组合 intertools.product(range(0, 1), range(0, 1)) 组合的情况[0, 0], [0, 1], [ ...