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

grequests/gevent与sshtunnel冲突导致SSH协议报错求助

grequests与sshtunnel冲突触发SSH协议读取错误:Error reading SSH protocol banner cannot switch to a different thread

我正在开发一个基于grequests的网页爬虫,需要通过sshtunnel将数据存入数据库,但遇到了依赖冲突问题:

  • 同时导入grequests和sshtunnel时,会触发错误:Error reading SSH protocol banner cannot switch to a different thread
  • 单独使用sshtunnel时功能完全正常,但项目必须保留grequests依赖,无法移除
  • 尝试过开启或关闭gevent的monkey补丁(包括设置thread=False, select=False),问题均未解决
  • 我的场景不需要并行SSH连接,仅在程序启动时建立一次连接加载数据,结束时建立一次连接存入新数据,但只要导入grequests就会触发错误,哪怕完全没有调用它的功能

相关代码片段:

from gevent import monkey
monkey.patch_all(thread=False, select=False)
import grequests
import mysql.connector
import sshtunnel

我在网上查到少量关于gevent与paramiko(sshtunnel的依赖库)存在冲突的讨论,但没有找到适配该报错的解决方案,其他相关问题的解决方法也无法解决我的问题。

请问有没有人遇到过相同的问题,或者有可行的解决方法?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 06:39:53