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 ...
随机推荐
- [原]DataGridView 回车不换行代码 AND 编辑时的字符控制
// 让 dataGridView1 在遇到回车时不响应 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { ...
- 1005 Spell It Right (20 分)
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...
- Eclipse里面的Maven项目打包(Maven build)
eclipse里面执行maven build打包的时候,如何设置参数? 主要就是设置一个goals
- JedisCluster中应用的Apache Commons Pool对象池技术
对象池技术在服务器开发上应用广泛.在各种对象池的实现中,尤其以数据库的连接池最为明显,可以说是每个服务器必须实现的部分. apache common pool 官方文档可以参考:https://c ...
- javascript的密封对象之seal(),isSealed()方法
EcmaScrip5t中出现了密封对象概念.密封对象不可扩展,而已有的成员的[Configurable]特性被设置为false.也就是说属性和方法是不能删除的.但是是可以修改的. 示例一: var p ...
- Spark分析之TaskScheduler
TaskScheduler概述: TaskScheduler是一个可插拔任务调度接口,通过不同的SchedulerBackend进行任务的调度.主要功能如下: 1.一个TaskScheduler只为一 ...
- MySQL 序列 AUTO_INCREMENT
MySQL序列是一组整数:1, 2, 3, ...,由于一张数据表只能有一个字段自增主键, 如果你想实现其他字段也实现自动增加,就可以使用MySQL序列来实现. 本章我们将介绍如何使用MySQL的序列 ...
- quartz 的简单使用
0.依赖: <!-- 引入quartz对应的依赖 --> <dependency> <groupId>org.quartz-scheduler</groupI ...
- jap 事务
事物传播行为介绍: @Transactional(propagation=Propagation.REQUIRED) :如果有事务, 那么加入事务, 没有的话新建一个(默认情况下) @Transact ...
- NavitForMySql 破解工具使用
Navicat 11.0注册机使用教程: 1.右键-管理员权限运行注册机2.选择对应的产品3.点击“补丁”按钮,选择文件4.点击“生成”按钮,生成序列号,并保存下授权文件5.复制序列号,打开软件,在弹 ...