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

urllib3报错TypeError: 'module' object is not callable的原因排查

问题原因及解决方法

错误原因

你直接调用了urllib3.request这个模块,而它本身不是可调用的函数,因此触发TypeError: 'module' object is not callable错误。

两种正确写法

方法1:使用连接池(官方推荐)

urllib3推荐通过PoolManager管理连接池,这是更规范的用法:

import urllib3
http = urllib3.PoolManager()
resp = http.request("GET", "https://httpbin.org/robots.txt")
resp.status, resp.data

方法2:调用模块内的request函数

如果要直接使用request功能,需要调用urllib3.request模块下的同名函数:

import urllib3
resp = urllib3.request.request("GET", "https://httpbin.org/robots.txt")
resp.status, resp.data

内容的提问来源于stack exchange,提问作者Uwe.Schneider

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 06:00:56