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

Git Push至Heroku Master失败:requirements.txt文件依赖安装报错

Fixing Heroku Deployment Failures for Your Python App

First, let's tackle the immediate error stopping your deployment:

ERROR: Could not find a version that satisfies the requirement anaconda-project0.9.1 (from -r /tmp/build_da51543d/requirements.txt (line 3)) (from versions: none)
ERROR: No matching distribution found for anaconda-project
0.9.1

Why this is happening

You're hitting two key issues:

  1. anaconda-project isn't hosted on PyPI: This package is exclusive to the Anaconda ecosystem—Heroku uses pip to install dependencies, which can only pull packages from the standard Python Package Index. It has no access to Anaconda's private repositories.
  2. Your requirements.txt is full of unnecessary bloat: You exported every package from your local Anaconda environment, including dozens of Anaconda-specific tools (like conda, spyder, anaconda-navigator) that your app doesn't need to run. These extra packages not only slow down deployment but also cause conflicts and missing package errors.

Step 1: Generate a clean, minimal requirements.txt

The best fix is to create a stripped-down list of only the packages your application actually depends on. Here's how:

  • Create a fresh virtual environment (use either Python's built-in venv or a new conda environment):
    # Using venv (recommended for Heroku)
    python -m venv app-env
    source app-env/bin/activate  # For Windows: app-env\Scripts\activate
    
    # Or using conda
    conda create --name app-env python=3.x
    conda activate app-env
    
  • Install only the packages your app needs (example for a Django + TensorFlow app):
    pip install django tensorflow opencv-python gunicorn pillow ...
    
  • Generate a clean requirements file:
    pip freeze > requirements.txt
    

Step 2: Quick patch for your existing file (if you don't want to rebuild the env)

If you want to fix your current requirements.txt immediately, manually delete all Anaconda-specific and development-only packages. These include:

  • anaconda-client, anaconda-navigator, anaconda-project
  • conda, conda-build, conda-package-handling, conda-verify
  • spyder, spyder-kernels, navigator-updater
  • Linting/development tools like pylint, autopep8, flake8 (unless your app requires them to run)

Step 3: Resolve the earlier absl-py error

The previous missing directory error for absl-py was almost certainly a temporary Heroku build cache glitch. With a clean requirements.txt, Heroku will pull the correct wheel for absl-py==0.11.0 directly from PyPI, no path issues included.

Final Deployment

After updating your requirements.txt, commit the changes and push again:

git add requirements.txt
git commit -m "Trim requirements.txt to only app dependencies"
git push heroku master

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 11:23:39