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

在Heroku上安装django-tables2时出错:无效命令‘egg_info’

Fixing the django-tables2==1.21.1 Installation Error on Heroku

First, let's recap the error you ran into (formatted for clarity):

~ $ pip install django-tables21.21.1
Collecting django-tables2
1.21.1
Using cached django-tables2-1.21.1.tar.gz
Complete output from command python setup.py egg_info:
/app/.heroku/python/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'extras_require'
warnings.warn(msg)
/app/.heroku/python/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option...

What's causing this?

The root issues are tied to Python version compatibility:

  • django-tables2 1.21.1 drops support for Python 2.7: Starting from version 1.20, django-tables2 only supports Python 3.5 and above. Your Heroku dyno is running Python 2.7, which is completely out of sync with this package version.
  • Outdated tooling warning: The extras_require warning pops up because your Python 2.7 environment uses the old, unmaintained distutils instead of setuptools (which adds support for that option). But this is just a side effect of using an outdated Python version.

How to fix it

You've got two solid options:

Option 1: Downgrade django-tables2 to a Python 2.7-compatible version

If you absolutely need to stick with Python 2.7 for now, install the last version of django-tables2 that supports it:

pip install django-tables2==1.11.2

This is the final stable release that works with Python 2.7, so it should install without those warnings.

Option 2: Upgrade your Heroku app to Python 3.x (highly recommended)

Python 2.7 has been end-of-life since 2020—no security updates, no new package support. It's worth making the switch:

  1. Create or edit a runtime.txt file in your project root to specify a supported Python 3 version (e.g.,):
python-3.8.18

(Heroku supports several 3.x versions; 3.7+ will work with django-tables2 1.21.1)
2. Update your requirements.txt to ensure all your dependencies (like Django) are compatible with Python 3.
3. Deploy the changes:

git add runtime.txt requirements.txt
git commit -m "Upgrade to Python 3.8 and update dependencies"
git push heroku main

Once deployed, running pip install django-tables2==1.21.1 will work as expected.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:02:43