You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python3 Windows环境下httplib2报'module' object is not callable错误求助

问题:httplib2 调用 iri2uri 时报错 TypeError: 'module' object is not callable

环境信息

  • Python 3.7.4(Windows 32位)
  • httplib2 版本 0.20.4(已尝试重装)

脚本代码

from httplib2 import httplib2
http = httplib2.Http()
content = http.request("http://mit.edu")[1] 

报错信息

uri = httplib2.iri2uri(uri) TypeError: 'module' object is not callable

终端操作过程

(mp4) C:\temp\ffmpeg\MP4\dev>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib2
>>> httplib2.iri2uri()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
>>> quit()

(mp4) C:\temp\ffmpeg\MP4\dev>pip install httplib2
Requirement already satisfied: httplib2 in c:\temp\ffmpeg\mp4\dev\mp4\lib\site-packages (0.20.4)
Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in c:\temp\ffmpeg\mp4\dev\mp4\lib\site-packages (from httplib2) (3.0.9)

(mp4) C:\temp\ffmpeg\MP4\dev>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from httplib2 import httplib2
>>> http = httplib2.Http()
>>> content = http.request("http://mit.edu")[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\temp\ffmpeg\MP4\dev\httplib2\__init__.py", line 1426, in request
    uri = httplib2.iri2uri(uri)
TypeError: 'module' object is not callable

解决方案

问题核心是当前脚本目录下存在同名的httplib2文件夹/模块,导致导入的不是系统安装的官方库,而是本地的模块。从报错路径C:\temp\ffmpeg\MP4\dev\httplib2\__init__.py可直接验证这一点。

解决步骤:

  1. 检查当前脚本所在目录C:\temp\ffmpeg\MP4\dev,删除或重命名本地的httplib2文件夹。
  2. 验证库加载路径:在终端执行import httplib2; print(httplib2.__file__),确认输出路径指向虚拟环境的site-packages目录下的官方库文件。
  3. 改用标准导入方式运行脚本:
import httplib2
http = httplib2.Http()
content = http.request("http://mit.edu")[1]

内容的提问来源于stack exchange,提问作者phill

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 02:01:16