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

使用python-espncricinfo模块运行示例代码时触发RecursionError: maximum recursion depth exceeded错误的求助

Fixing RecursionError When Running python-espncricinfo Code

What's Going On Here

That RecursionError: maximum recursion depth exceeded popping up in ssl.py isn't a core bug in the espncricinfo module itself. It's almost certainly a compatibility clash between your installed urllib3/requests versions and Python 3.9—specifically around how SSL contexts are being generated under the hood when the module makes API calls.

Step-by-Step Fixes to Try

1. Downgrade urllib3 to a Compatible Version

This recursion bug shows up in certain urllib3 releases paired with Python 3.9. Roll back to a stable, tested version:

pip install urllib3==1.26.6

2. Update Your Requests Library

Outdated requests versions can misalign with urllib3, worsening compatibility issues. Make sure you're on a recent, compatible build:

pip install --upgrade requests

3. Switch Python Versions (If Possible)

Python 3.9 has some known quirks with SSL context handling in older dependency libraries. Try switching to Python 3.8 or 3.10+—many users report this resolves the issue immediately without further tweaks.

4. Manually Patch the Module's Request Logic (Temporary Workaround)

If the above steps don't work, you can modify the espncricinfo module's match.py to bypass the broken SSL context generation:

  1. Open C:\Users\George\AppData\Local\Programs\Python\Python39\lib\site-packages\espncricinfo\match.py in a text editor
  2. Replace the existing get_json method with this modified version:
import ssl
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager

class SSLAdapter(HTTPAdapter):
    def init_poolmanager(self, *args, **kwargs):
        context = ssl.create_default_context()
        context.options &= ~ssl.OP_NO_SSLv3
        kwargs['ssl_context'] = context
        return super().init_poolmanager(*args, **kwargs)

def get_json(self):
    session = requests.Session()
    session.mount('https://', SSLAdapter())
    r = session.get(self.json_url)
    r.raise_for_status()
    return r.json()

This creates a manual SSL context that avoids the recursive loop in the default setup.

Is This a Universal Module Issue?

Nope—this is an environment-specific problem, not a flaw in the espncricinfo module itself. Plenty of users run the example code successfully with the right Python/dependency version combinations. Start with the version adjustments first, as those are the quickest fixes.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 13:47:30