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

MacOS环境下requests库报错:module 'requests' has no attribute 'SESSION'求助

Fixing AttributeError: module 'requests' has no attribute 'SESSION'

Hey there! Let's get this error sorted out quickly.

The Root Cause

This error is almost certainly a case-sensitive spelling mistake. In the requests library, the session class is named Session (only the first letter is uppercase, rest are lowercase). When you write requests.SESSION (all uppercase), Python treats this as an entirely different identifier that doesn't exist in the library—hence the "no attribute" error.

How to Fix It

  1. Go through your code and replace every instance of requests.SESSION with requests.Session.
  2. Here's a quick example of how to use the session correctly:
import requests

# Create a valid Session object
my_session = requests.Session()

# Use the session to send a request
response = my_session.get("https://example.com")
print(response.status_code)

Extra Checks (If the Error Persists)

  • Confirm requests is properly installed: Run pip3 show requests in your terminal—this should display details about the installed version.
  • If needed, upgrade requests (though for Python 3.5.3, you'll get the latest compatible version):
    pip3 install --upgrade requests
    
  • A side note: Python 3.5.3 is no longer supported (reached end-of-life in 2020). If possible, upgrading to a newer Python version (like 3.8 or higher) will give you better security and access to newer library features.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 10:07:34