在Heroku上部署Django应用时出现的问题:推送被拒绝错误

4 投票
2 回答
583 浏览
提问于 2025-04-17 22:16

我在Heroku上有一个Django应用。我在同一个Heroku账户上又设置了一个新的应用。

现在我想要第一个应用的另一个实例。

我只是把第一个应用复制了一份,然后推送到新创建的应用里,但它没有正常工作。

在执行 git push heroku master 时出现了这个错误。

        Running setup.py install for distribute
           Before install bootstrap.
           Scanning installed packages
           Setuptools installation detected at /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg
           Egg installation
           Patching...
           Renaming /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg into /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg.OLD.1394782343.31
           Patched done.
           Relaunching...
           Traceback (most recent call last):
             File "<string>", line 1, in <module>
           NameError: name 'install' is not defined
           Complete output from command /app/.heroku/python/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_u57096/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TYqPAN-record/install-record.txt --single-version-externally-managed --compile:
           Before install bootstrap.

       Scanning installed packages

       Setuptools installation detected at /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg

       Egg installation

       Patching...

       Renaming /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg into /app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg.OLD.1394782343.31

       Patched done.

       Relaunching...

       Traceback (most recent call last):

         File "<string>", line 1, in <module>

       NameError: name 'install' is not defined

       ----------------------------------------
       Cleaning up...
       Command /app/.heroku/python/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_u57096/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TYqPAN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_u57096/distribute
       Storing debug log for failure in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

To git@heroku.com:gentle-plateau-6569.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:gentle-plateau-6569.git'

我的requirements.txt文件是

Django==1.4
South==0.7.5
boto==2.5.2
distribute==0.6.27
dj-database-url==0.2.1
django-debug-toolbar==0.9.4
django-flash==1.8
django-mailgun==0.2.1
django-registration==0.8
django-session-security==2.0.3
django-sslify==0.2
django-storages==1.1.5
gunicorn==0.14.6
ipdb==0.7
ipython==0.13
newrelic==1.6.0.13
psycopg2==2.4.5
raven==2.0.3
requests==0.13.6
simplejson==2.4.0
wsgiref==0.1.2
xlrd==0.7.9
xlwt==0.7.4

请帮我解决这个问题。

2 个回答

0

virtualenv 是一个用来创建独立 Python 环境的工具。

为了修复 command python setup.py egg_info failed with error code 1 这个问题,你需要在你的 requirements.txt 文件里添加以下内容:

virtualenv==12.0.7

1

这似乎和一个问题有关,具体可以查看这里

换句话说,distribute这个工具已经不再使用了,正在被setuptools替代。你可以试着把代码中的distribute==0.6.27替换成setuptools>=0.7,这个建议可以在上面的链接中找到。

撰写回答