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

Heroku部署Python应用报错:无法导入InsecureRequestWarning

Fixing "ImportError: cannot import name 'InsecureRequestWarning'" on Heroku Python 3.6.4 Deployment

Let's break down what's happening and how to resolve this issue quickly:

Root Cause

This error comes down to incompatible dependency versions—specifically with requests and urllib3. Python 3.6.4 is end-of-life (EOL), meaning newer releases of these libraries have dropped support for it. Even though you only modified your README.md, Heroku’s build process reinstalls dependencies during deployment. If your Pipfile/Pipfile.lock didn’t pin compatible versions, Heroku pulled in updated library versions that break the InsecureRequestWarning import.

Step-by-Step Fix

  1. Pin compatible dependency versions locally
    Run these commands in your project directory to install the last versions of requests and urllib3 that officially support Python 3.6.4:

    pipenv install requests==2.27.1 urllib3==1.26.15
    
  2. Update your lock file
    Generate an updated Pipfile.lock to guarantee Heroku installs exactly these compatible versions:

    pipenv lock
    
  3. Commit and redeploy
    Add the updated Pipfile and Pipfile.lock to your testing branch, commit the changes, and push to Heroku again:

    git add Pipfile Pipfile.lock
    git commit -m "Pin requests/urllib3 versions for Python 3.6 compatibility"
    git push heroku testing:master
    

Long-Term Recommendation

Python 3.6 reached end-of-life in December 2021, so it no longer receives security updates or library support. For long-term stability and security, plan to upgrade your application to a supported Python version (e.g., 3.8 or newer). This will eliminate dependency compatibility issues like this in the future.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:11:19