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

Heroku部署报错:应用与Python Buildpack不兼容,含requirements.txt求帮助

Troubleshooting Heroku Python Buildpack Detection Failure

Hey there, let's work through this Heroku build issue together! Even though you’ve included a requirements.txt file, there are a handful of common snags that might be causing the buildpack detection to fail. Here’s what to check:

  • Confirm requirements.txt is in the root directory
    Heroku’s Python buildpack only looks for this file directly in your project’s root folder, not in subdirectories. Double-check with ls (Mac/Linux) or dir (Windows) in your local project root to make sure it’s placed correctly.

  • Validate the file’s content
    An empty or malformed requirements.txt can trigger a detection failure. Open the file and ensure it has at least one valid Python package dependency (e.g., requests>=2.25.1). Watch out for typos in package names, duplicate entries, or odd encoding issues that might throw off the buildpack.

  • Ensure the file is tracked by git
    If requirements.txt isn’t committed to git, Heroku won’t see it when you push. Run git status to check its status—if it’s untracked, run these commands:

    git add requirements.txt
    git commit -m "Add requirements.txt to track dependencies"
    

    Then try pushing to Heroku again.

  • Manually set the Python buildpack
    Sometimes Heroku’s auto-detection misses the mark. Force the Python buildpack with this command:

    heroku buildpacks:set heroku/python
    

    After setting it, push your code again with git push heroku main (replace main with your branch name if needed).

  • Check for conflicting buildpacks
    If you’ve previously added other buildpacks, they might interfere. Run heroku buildpacks to list active buildpacks—make sure only heroku/python is present. Remove any extra ones with:

    heroku buildpacks:remove <buildpack-name>
    

Give these steps a try in order, and your app should deploy successfully soon!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:25:15