Heroku push rejected due to pip/distribute bug. What's the workaround?

人走茶凉 提交于 2019-12-05 18:42:35

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!