LoginSignup
5
3

More than 5 years have passed since last update.

Django Girls TutorialでHerokuのデプロイでエラーとなるときの解決方法

Posted at

Django Girls Tutorial

Djangoチュートリアルを進めていたところ、デプロイ!でエラーとなってしまいました。
https://djangogirlsjapan.gitbooks.io/workshop_tutorialjp/content/deploy/

デプロイする

チュートリアルの「Deploy to Heroku!」のところでアプリケーションをデプロイしようとすると失敗します。

$ git push heroku master

ログを確認する

下記のログが出力されます。(エラー情報のみ抜粋)

remote:        Collecting psycopg2==2.5.4 (from -r /tmp/build_d1bbbafb62fca475e7098fdd83d9df07/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/63/c3/802668cb3cfc2880c2a8364623e7105a0257724a2612bb66ec733aaddb8c/psycopg2-2.5.4.tar.gz (682kB)
remote:            Complete output from command python setup.py egg_info:
remote:            running egg_info
remote:            creating pip-egg-info/psycopg2.egg-info
remote:            writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
remote:            writing pip-egg-info/psycopg2.egg-info/PKG-INFO
remote:            writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
remote:            writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
remote:            Error: could not determine PostgreSQL version from '10.5'
remote:            
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7lkslusa/psycopg2/
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed

psycopg2をアップデートする

psycopg2のバージョンが原因でした。チュートリアルの手順に従ってインストールするとバージョンが古いようです。下記コマンドでインストールします。

$ pip install psycopg2

requirements.txtを修正する

requirements.txtのpsycopg2のバージョンを修正します。(下記はインストールされたバージョンで修正してください。)

psycopg2==2.7.5

最後に、Gitで変更を保存、プッシュします。

補足

事前にインストールしていたPythonのバージョンが合っていないと思い込み、runtime.txtを何度も修正していましたが、これは原因ではなかったようです。

(venv)$ python --version
Python 3.6.5

下記のログが出力されていました。

remote: -----> Python app detected
remote:  !     The latest version of Python 3.6 is python-3.6.6 (you are using python-3.6.5, which is unsupported).
remote:  !     We recommend upgrading by specifying the latest version (python-3.6.6).
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtime
remote: -----> Installing python-3.6.5
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3