由于点/分发错误,Heroku推送被拒绝。什么是解决方法? [英] Heroku push rejected due to pip/distribute bug. What's the workaround?

查看:182
本文介绍了由于点/分发错误,Heroku推送被拒绝。什么是解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地git / virtualenv使用 pip 版本1.3.1。当我尝试将我的Python 3.3.2应用程序推送到Heroku时,我得到

 下载/解包分布== 0.6.34来自-r requirements.txt(第5行))
运行setup.py egg_info包发布
Traceback(最近一次调用最后一次):
文件< string>,第3行,在< module>
文件./setuptools/__init__.py,第2行,位于< module>
from setuptools.extension import Extension,Library
文件./setuptools/extension.py,第5行,位于< module>
from setuptools.dist import _get_unpatched
文件./setuptools/dist.py,第103行
ValueError除外,e:
^
语法错误:语法无效
从命令python setup.py完整输出egg_info:
Traceback(最近一次调用最后一次):

在< module>文件中的< string>

文件./setuptools/__init__.py,第2行,位于< module>

from setuptools.extension import Extension,Library

文件./setuptools/extension.py,第5行,位于< module>

from setuptools.dist import _get_unpatched

文件./setuptools/dist.py,第103行

除ValueError外,e:

^

SyntaxError:语法无效

----------------------- -----------------
命令python setup.py egg_info失败,错误代码1在/ tmp / pip-build-u58345 / distribute
中存储完整日志在/app/.pip/pip.log

!由于我无法手动安装在Heroku的服务器上分发,我应该如何避免这个bug?

解决方案

看到的是pip本身的问题:
https://github.com/pypa/pip / issues / 650



看起来pip使用distribute来升级分发。


然而,你需要做什么来解决你的错误是从requires.txt中删除分发。它已经存在,因为它是由buildpack安装的,并且不需要使用pip再次安装。



我相信你实际上可以通过默认的buildpack。 Heroku的Python支持以buildpack的形式实现。您可以在此处阅读有关buildpack的更多信息。



<如果你希望有一个特定的发布版本,在这种情况下你不需要使用pip-bug,你必须在你的应用使用的buildpack中取代它。可以这样做:


  1. 从heroku的 https://github.com/heroku/heroku-buildpack-python

  2. 在你的克隆的buildpack中写这篇文章的时候),你会发现 /vendor/distribute-0.6.36 。这就是问题。将其替换为分发的新版本

  3. 在buildpack的 bin / compile 脚本中,替换buildpack正在使用的版本。在我的情况下,这是取代第31行 DISTRIBUTE_VERSION =0.6.36 DISTRIBUTE_VERSION =0.6.45


  4. 将你的buildpack上传到github,然后告诉heroku使用它


$ heroku config:set BUILDPACK_URL = https://github.com/you/name-of-buildpack-python-repo.git



ALTERNATIVELY



告诉heroku使用我的自定义buildpack,而不是原始的。我的builbpack与原始文件的唯一区别在步骤1-4中描述。



覆盖现有应用程序的buildpack:

$ heroku config:set BUILDPACK_URL = https://github.com/jhnwsk/heroku-buildpack-python.git



或者如果您正在创建一个新的应用程序



$ heroku create myapp --buildpack https://github.com/jhnwsk/heroku-buildpack-python.git



当您在进行这些更改后将应用程序推送到Heroku时,您应该看到类似于

  ----->获取定制git buildpack ... done 
-----> Python应用程序检测到
----->没有提供runtime.txt;假定python-2.7.4。
----->准备Python运行时(python-2.7.4)
----->安装分发(0.6.45)
----->安装Pip(1.3.1)

这意味着您的定制分发版本正在运行。


My local git/virtualenv is using pip version 1.3.1. When I try to push my Python 3.3.2 app to Heroku, I get

Downloading/unpacking distribute==0.6.34 (from -r requirements.txt (line 5))
     Running setup.py egg_info for package distribute
       Traceback (most recent call last):
         File "<string>", line 3, in <module>
         File "./setuptools/__init__.py", line 2, in <module>
           from setuptools.extension import Extension, Library
         File "./setuptools/extension.py", line 5, in <module>
           from setuptools.dist import _get_unpatched
         File "./setuptools/dist.py", line 103
           except ValueError, e:
                            ^
       SyntaxError: invalid syntax
       Complete output from command python setup.py egg_info:
       Traceback (most recent call last):

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

     File "./setuptools/__init__.py", line 2, in <module>

       from setuptools.extension import Extension, Library

     File "./setuptools/extension.py", line 5, in <module>

       from setuptools.dist import _get_unpatched

     File "./setuptools/dist.py", line 103

       except ValueError, e:

                        ^

   SyntaxError: invalid syntax

   ----------------------------------------
   Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-u58345/distribute
   Storing complete log in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

Given I can't manually install distribute on Heroku's servers, how am I supposed to avoid this bug?

解决方案

The behaviour you are seeing is an issue with pip itself: https://github.com/pypa/pip/issues/650

It seems that pip uses distribute to upgrade distribute.

However, what you need to do to fix your error is remove distribute from requirements.txt altogether. It's already there since it's being installed by the buildpack and there's no need to install it again using pip.

I believe you actually CAN and ARE installing distribute on heroku's servers via the default buildpack. Heroku's Python support is implemented in the form of a buildpack. You can read more about buildpacks here.

If you wish to have a specific version of distribute, in this case one without the pip-bug, you have to replace it's source within the buildpack your app is using. It can be done like so:

  1. Get the original buildpack from heroku at https://github.com/heroku/heroku-buildpack-python
  2. In your cloned buildpack (at the time of this writing) you will find /vendor/distribute-0.6.36. This is the problem. Replace it with a newer version of distribute.
  3. Inside the buildpack's bin/compile script, replace the version of distribute the buildpack is using. In my case this was replacing line 31 DISTRIBUTE_VERSION="0.6.36" with DISTRIBUTE_VERSION="0.6.45"

  4. Upload your buildpack to github and tell heroku to use it by saying

$ heroku config:set BUILDPACK_URL=https://github.com/you/name-of-buildpack-python-repo.git

ALTERNATIVELY

Tell heroku to use my custom buildpack instead of the original. My builbpack's only differences to the original are those described in steps 1-4.

To override the buildpack for an existing application:

$ heroku config:set BUILDPACK_URL=https://github.com/jhnwsk/heroku-buildpack-python.git

Or if you are creating a new application

$ heroku create myapp --buildpack https://github.com/jhnwsk/heroku-buildpack-python.git

When you push your application to Heroku after making these changes you should see something like

-----> Fetching custom git buildpack... done
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.45)
-----> Installing Pip (1.3.1)

which means you have your custom distribute version running.

这篇关于由于点/分发错误,Heroku推送被拒绝。什么是解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆