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

使用requests.get调用SOCKS代理报错:缺少SOCKS支持依赖

解决requests使用SOCKS代理时「Missing dependencies for SOCKS support」错误

你的问题核心出在导入语句错误,from socks import requests这行代码会覆盖标准的requests库,导致无法正确加载SOCKS代理所需的扩展支持。即使你已经安装了requests[socks]和pysocks,错误的导入也会让这些依赖无法生效。

解决步骤:

  • 删掉错误的导入语句from socks import requests,只保留import requests。安装requests[socks]后,requests会自动集成pysocks的功能,无需额外导入socks模块里的requests。
  • 若仍有问题,重新执行安装命令确保依赖完整兼容Python3.11:
    pip install --upgrade requests[socks] pysocks
    

修正后的完整代码:

import requests

# 填入你的代理信息
proxies = {
    'http': 'socks5://myinfo',
    'https': 'socks5://myinfo'
}

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36"
}
response = requests.get('http://neverssl.com', headers=headers, proxies=proxies, timeout=15)
print(response.content)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 05:09:57