2013-06-05 30 views
3

我的本地git/virtualenv正在使用版本1.3.1的pip。當我嘗試我的Python 3.3.2應用推到Heroku的,我得到由於點/分發錯誤,Heroku推送被拒絕。什麼是解決方法?

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 

鑑於我無法手動安裝在Heroku的服務器distribute,我應該如何避免這種錯誤?

回答

3

您所看到的行爲與PIP本身的問題: https://github.com/pypa/pip/issues/650

看來,PIP使用分發升級分發。

但是,您需要做什麼來解決您的錯誤是從requirements.txt中刪除分發。它已經存在,因爲它由buildpack安裝,並且不需要使用pip再次安裝它。

我相信你實際上可以通過默認的buildpack安裝在heroku的服務器上。 Heroku的Python支持以buildpack的形式實現。您可以閱讀關於buildpack的更多信息here

如果您希望擁有特定版本的分發版,在這種情況下,您不必使用pip-bug,您必須在您的應用正在使用的buildpack中替換它的源代碼。這是可以做到像這樣:

  1. https://github.com/heroku/heroku-buildpack-python
  2. 獲取從Heroku的原buildpack在你克隆buildpack(在寫這篇文章的時候),你會發現/vendor/distribute-0.6.36。這就是問題。將其替換爲a newer version of distribute
  3. 在buildpack的bin/compile腳本中,替換buildpack正在使用的版本。在我的情況,這是replacing line 31DISTRIBUTE_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

使用它或者

告訴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你應該看到類似於

-----> 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) 

這意味着您的自定義分發版本正在運行。

+0

如果您不介意,您是否願意詳細介紹這四個步驟?這些對我的新人毫無意義。 –

+0

當然可以。我編輯我的答案是更詳細的,雖然我不知道這是否變得更糟或更好。如果你告訴我哪些部分不清楚,我們可以制定更有意義的東西:) – jhnwsk

相關問題