尝试将Django应用程序部署到Heroku时,我收到了拒绝错误。我在这里查看了可能的解决方案:
Heroku push rejected, failed to compile Python/django app (Python 2.7)
但这对我没有用。
这是从启动推送到heroku的流程:
git push heroku master
Initializing repository, done.
Counting objects: 7024, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5915/5915), done.
Writing objects: 100% (7024/7024), 8.77 MiB | 104 KiB/s, done.
Total 7024 (delta 2183), reused 0 (delta 0)
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.6.
-----> Preparing Python runtime (python-2.7.6)
-----> Installing Setuptools (2.1)
-----> Installing Pip (1.5.4)
-----> Installing dependencies using Pip (1.5.4)
Downloading/unpacking Django==1.6.2 (from -r requirements.txt (line 1))
Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 2))
argparse an externally hosted file and may be unreliable
Running setup.py (path:/tmp/pip_build_u16439/argparse/setup.py) egg_info for package argparse
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
Downloading/unpacking distribute==0.6.24 (from -r requirements.txt (line 3))
Running setup.py (path:/tmp/pip_build_u16439/distribute/setup.py) egg_info for package distribute
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
Downloading/unpacking dj-database-url==0.3.0 (from -r requirements.txt (line 4))
Downloading dj_database_url-0.3.0-py2.py3-none-any.whl
Downloading/unpacking dj-static==0.0.5 (from -r requirements.txt (line 5))
Downloading dj-static-0.0.5.tar.gz
Running setup.py (path:/tmp/pip_build_u16439/dj-static/setup.py) egg_info for package dj-static
Downloading/unpacking django-toolbelt==0.0.1 (from -r requirements.txt (line 6))
Downloading django-toolbelt-0.0.1.tar.gz
Running setup.py (path:/tmp/pip_build_u16439/django-toolbelt/setup.py) egg_info for package django-toolbelt
Downloading/unpacking gunicorn==18.0 (from -r requirements.txt (line 7))
Running setup.py (path:/tmp/pip_build_u16439/gunicorn/setup.py) egg_info for package gunicorn
Downloading/unpacking psycopg2==2.5.2 (from -r requirements.txt (line 8))
Running setup.py (path:/tmp/pip_build_u16439/psycopg2/setup.py) egg_info for package psycopg2
Downloading/unpacking pystache==0.5.3 (from -r requirements.txt (line 9))
Running setup.py (path:/tmp/pip_build_u16439/pystache/setup.py) egg_info for package pystache
pystache: using: version '2.1' of <module 'setuptools' from '/app/.heroku/python/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg/setuptools/__init__.pyc'>
Downloading/unpacking static==1.0.2 (from -r requirements.txt (line 10))
Downloading static-1.0.2.tar.gz
Running setup.py (path:/tmp/pip_build_u16439/static/setup.py) egg_info for package static
Installing collected packages: Django, argparse, distribute, dj-database-url, dj-static, django-toolbelt, gunicorn, psycopg2, pystache, static
Running setup.py install for argparse
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
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.1397160440.32
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_u16439/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7JPdSe-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.1397160440.32
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_u16439/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7JPdSe-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_u16439/distribute
Storing debug log for failure in /app/.pip/pip.log
! Push rejected, failed to compile Python app
我的requirements.txt
Django==1.6.2
argparse==1.2.1
distribute==0.6.24
dj-database-url==0.3.0
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.2
pystache==0.5.3
static==1.0.2
wsgiref==0.1.2
Procfile
web: gunicorn app.wsgi
我已按照Heroku网站的说明进行操作。知道我错过了什么吗?
答案 0 :(得分:2)
这显然是bug in the distribute
package,似乎不太可能得到修复:
分发现在被视为已弃用,并由setuptools取代。我建议在requirements.txt中用'setuptools == 1.0'或类似替换'distribute == 0.6.28'。最新版本的pip(&gt; = 1.4)和setuptools(&gt; = 0.7)可以更好地支持统一代码和升级,并寻求避免像这里遇到的问题。
答案 1 :(得分:1)
这是已弃用的distribute
包的问题。请参阅Bitbucket上的Bug #91。
用 requirements.txt 文件中的distribute==0.6.24
替换setuptools==0.7.3
可以解决您的问题。
答案 2 :(得分:0)
在将Heroku堆栈从cedar-14(旧的和已弃用的)升级到Heroku-18(新的)之前,我一直遇到此错误。然后一切正常。
答案 3 :(得分:-1)
推送到heroku也有类似的问题:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-2.7.13
remote: $ pip install -r requirements.txt
remote: Collecting Django==1.10 (from -r /tmp/build_9bc106d48b24e071b3b58
3f8cd5119f8/requirements.txt (line 1))
remote: Downloading Django-1.10-py2.py3-none-any.whl (6.8MB)
remote: Collecting get==0.0.0 (from -r /tmp/build_9bc106d48b24e071b3b583f
8cd5119f8/requirements.txt (line 2))
remote: Downloading get-0.0.0.tar.gz
remote: Complete output from command python setup.py egg_info:
remote: Traceback (most recent call last):
remote: File "<string>", line 1, in <module>
remote: IOError: [Errno 21] Is a directory: '/tmp/pip-build-h774_8/ge
t/setup.py'
remote:
remote: ----------------------------------------
remote: Command "python setup.py egg_info" failed with error code 1 in /t
mp/pip-build-h774_8/get/
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to enigmatic-bastion-36926.
remote:
To https://git.heroku.com/enigmatic-bastion-36926.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/enigmatic-bastion-369
26.git
我的要求.txt:
Django==1.10
get==0.0.0
gunicorn==19.6.0
olefile==0.44
Pillow==4.0.0
post==0.0.0
public==0.0.0
query-string==0.0.0
request==0.0.0
requests==2.12.4
setupfiles==0.0.0
virtualenv==15.1.0
whitenoise==3.2