git push heroku master - 无法编译Python应用程序

时间:2014-04-11 00:14:53

标签: python git heroku

我是git,heroku和python的全新手。我是网络架构师而不是开发人员。但是,我正在开展一个项目,要求我进入开发世界。

我正在按照此Plivo博客的说明操作: https://plivo.com/docs/integrations/hipchat-api/

当我运行“git push heroku master”时,它会失败并显示以下内容(这是输出开头和结尾的结束:

# git push heroku master
Enter passphrase for key '/root/.ssh/id_rsa': 
Initializing repository, done.
Counting objects: 18, done.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 9.26 KiB, done.
Total 18 (delta 4), 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 Flask==0.10.1 (from -r requirements.txt (line 1))
         Running setup.py (path:/tmp/pip_build_u51681/Flask/setup.py) egg_info for package Flask

           warning: no files found matching '*' under directory 'tests'
           no previously-included directories found matching 'docs/_build'
           no previously-included directories found matching 'docs/_themes/.git'
       Downloading/unpacking Jinja2==2.7.1 (from -r requirements.txt (line 2))
         Running setup.py (path:/tmp/pip_build_u51681/Jinja2/setup.py) egg_info for package Jinja2

。 。

 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.1397173205.08

       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_u51681/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FRUnI0-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_u51681/distribute
       Storing debug log for failure in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

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

当我查看文件/app/.pip/pip.log时,它显示以下内容:

# cat /root/.pip/pip.log 

------------------------------------------------------------
/usr/bin/pip run on Thu Apr 10 19:08:31 2014
Exception:
Traceback (most recent call last):

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/commands/install.py", line 257, in run
    InstallRequirement.from_line(name, None))

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 172, in from_line
    return cls(req, comes_from, url=url, prereleases=prereleases)

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 70, in __init__
    req = pkg_resources.Requirement.parse(req)

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/pkg_resources.py", line 2606, in parse
    reqs = list(parse_requirements(s))

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/pkg_resources.py", line 2544, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")

  File "/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/pkg_resources.py", line 2512, in scan_list
    raise ValueError("Expected "+item_name+" in",line,"at",line[p:])

ValueError: ('Expected version spec in', 'argparse,', 'at', ',')

有人能告诉我如何解决这个问题吗?感谢您提供任何帮助。

2014年4月21日更新:

以下是从requirements.txt中删除argparse后命令的最新输出:

[root@clearos wrench]# git push heroku master
Enter passphrase for key '/root/.ssh/id_rsa': 
Enter passphrase for key '/root/.ssh/id_rsa': 
Initializing repository, done.
Counting objects: 18, done.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 9.26 KiB, done.
Total 18 (delta 4), 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 Flask==0.10.1 (from -r requirements.txt (line 1))
         Running setup.py (path:/tmp/pip_build_u51702/Flask/setup.py) egg_info for package Flask

           warning: no files found matching '*' under directory 'tests'
           no previously-included directories found matching 'docs/_build'
           no previously-included directories found matching 'docs/_themes/.git'
       Downloading/unpacking Jinja2==2.7.1 (from -r requirements.txt (line 2))
         Running setup.py (path:/tmp/pip_build_u51702/Jinja2/setup.py) egg_info for package Jinja2

           warning: no files found matching '*' under directory 'custom_fixers'
       Downloading/unpacking MarkupSafe==0.18 (from -r requirements.txt (line 3))
         Downloading MarkupSafe-0.18.tar.gz
         Running setup.py (path:/tmp/pip_build_u51702/MarkupSafe/setup.py) egg_info for package MarkupSafe

       Downloading/unpacking Werkzeug==0.9.4 (from -r requirements.txt (line 4))
         Running setup.py (path:/tmp/pip_build_u51702/Werkzeug/setup.py) egg_info for package Werkzeug

           warning: no files found matching '*' under directory 'werkzeug/debug/templates'
           warning: no files found matching '*' under directory 'tests'
           no previously-included directories found matching 'docs/_build'
       Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 5))
         argparse an externally hosted file and may be unreliable
         Running setup.py (path:/tmp/pip_build_u51702/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.27 (from -r requirements.txt (line 6))
         Running setup.py (path:/tmp/pip_build_u51702/distribute/setup.py) egg_info for package distribute

       Downloading/unpacking itsdangerous==0.23 (from -r requirements.txt (line 7))
         Running setup.py (path:/tmp/pip_build_u51702/itsdangerous/setup.py) egg_info for package itsdangerous

       Downloading/unpacking plivo==0.9.1 (from -r requirements.txt (line 8))
         Downloading plivo-0.9.1.tar.gz
         Running setup.py (path:/tmp/pip_build_u51702/plivo/setup.py) egg_info for package plivo

       Downloading/unpacking python-dateutil==2.1 (from -r requirements.txt (line 9))
         Running setup.py (path:/tmp/pip_build_u51702/python-dateutil/setup.py) egg_info for package python-dateutil

       Downloading/unpacking python-simple-hipchat==0.1 (from -r requirements.txt (line 10))
         Downloading python-simple-hipchat-0.1.zip
         Running setup.py (path:/tmp/pip_build_u51702/python-simple-hipchat/setup.py) egg_info for package python-simple-hipchat

       Downloading/unpacking pytz==2013d (from -r requirements.txt (line 11))
         Running setup.py (path:/tmp/pip_build_u51702/pytz/setup.py) egg_info for package pytz

           warning: no files found matching '*.pot' under directory 'pytz'
       Downloading/unpacking redis==2.8.0 (from -r requirements.txt (line 12))
         Running setup.py (path:/tmp/pip_build_u51702/redis/setup.py) egg_info for package redis

       Downloading/unpacking requests==1.2.3 (from -r requirements.txt (line 13))
         Running setup.py (path:/tmp/pip_build_u51702/requests/setup.py) egg_info for package requests

       Downloading/unpacking rq==0.3.11 (from -r requirements.txt (line 14))
         Downloading rq-0.3.11.tar.gz
         Running setup.py (path:/tmp/pip_build_u51702/rq/setup.py) egg_info for package rq

       Downloading/unpacking simplejson==3.3.0 (from -r requirements.txt (line 15))
         Running setup.py (path:/tmp/pip_build_u51702/simplejson/setup.py) egg_info for package simplejson

       Downloading/unpacking six==1.4.1 (from -r requirements.txt (line 16))
         Downloading six-1.4.1.tar.gz
         Running setup.py (path:/tmp/pip_build_u51702/six/setup.py) egg_info for package six

       Downloading/unpacking times==0.6.2 (from -r requirements.txt (line 17))
         Downloading times-0.6.2-py2.py3-none-any.whl
       Installing collected packages: Flask, Jinja2, MarkupSafe, Werkzeug, argparse, distribute, itsdangerous, plivo, python-dateutil, python-simple-hipchat, pytz, redis, requests, rq, simplejson, six, times
         Running setup.py install for Flask

           warning: no files found matching '*' under directory 'tests'
           no previously-included directories found matching 'docs/_build'
           no previously-included directories found matching 'docs/_themes/.git'
         Running setup.py install for Jinja2

           warning: no files found matching '*' under directory 'custom_fixers'
         Running setup.py install for MarkupSafe

           building 'markupsafe._speedups' extension
           gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o
           gcc -pthread -shared build/temp.linux-x86_64-2.7/markupsafe/_speedups.o -o build/lib.linux-x86_64-2.7/markupsafe/_speedups.so
         Running setup.py install for Werkzeug

           warning: no files found matching '*' under directory 'werkzeug/debug/templates'
           warning: no files found matching '*' under directory 'tests'
           no previously-included directories found matching 'docs/_build'
         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.1398135525.78
           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_u51702/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-HEnm1N-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.1398135525.78

       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_u51702/distribute/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-HEnm1N-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_u51702/distribute
       Storing debug log for failure in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

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

2 个答案:

答案 0 :(得分:1)

最后一行:

ValueError: ('Expected version spec in', 'argparse,', 'at', ',')

让我觉得在requirements.txt文件中,您有argparseargparse是内置的,有时会错误地通过pip freeze(以及wsgiref)输出。你能检查那个文件并删除该行吗?

另见this answer

答案 1 :(得分:1)

我怀疑当您使用某个版本的requirements.txt时,distribute的旧版本setuptools。请参阅Django deployment issue on Heroku with exact clone of running app: PUSH REJECTED ERROR