LoginSignup
6
2

More than 5 years have passed since last update.

Django girls でHerokuにpushできなかった時の話

Posted at

Django girlsをやってたところ、デプロイ!のHerokuにアップする時少しつまづいたのでメモ

https://djangogirlsjapan.gitbooks.io/workshop_tutorialjp/content/deploy/

【事象】

Django girlsチュートリアルの手順に則り、以下コマンドでHerokuにアップロードしようとしたところ..

git push heroku master

Pushに失敗

remote: ! Push rejected, failed to compile Python app.
remote: 
remote: ! Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to mokumoku-blog-20180630.

【原因】

原因は2つ
①Django girlsチュートリアルの「runtime.txt」に記載していたPythonのバージョンと、自分のPCに導入していたPythonのバージョンが異なっていた。

(myenv) TakunoMacBook-Pro:djangogirls2 taku$ python --version
Python 3.6.5

The runtime.txt file
Herokuに使っているPythonのバージョンを伝えなければいけません。djangogirlsディレクトリにruntime.txt ファイルを作ってその中に書きます。エディタで新規ファイルを作成して、次のように書いてください:

python-3.5.2

※事前にPythonを導入しており、以下手順はスキップしていた。(3.6.5をインストール)

https://djangogirlsjapan.gitbooks.io/workshop_tutorialjp/content/python_installation/

=>これも3.6.2でruntime.txtで記載してみようとされていたバージョンと違うのだが・・

②psycopg2のバージョンが古い
チュートリアルの手順だと、必要なバージョンが導入されないらしい。

psycopg2のアップデートが必要

【解決策】

①runtime.txtの記載を修正

runtime.txt

python-3.6.5

修正後、以下コマンドで設定を反映

$ pip freeze > requirements.txt

②psycopg2のアップデート
以下コマンドを実行

pip install --upgrade psycopg2

 (参考)

Djangoでherokuを使おうとした時, git push heroku master ができなかった話
https://qiita.com/rym903/items/14571f056463e924f742

①、②を実行後、次のコマンドで反映

$ git add -A .
$ git commit -m "My Django Girls app"

反映後、git push すると、git(Heroku)へのアップロードは成功

remote: -----> Launching...
remote: Released v4
remote: https://mokumoku-blog-20180630.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/mokumoku-blog-20180630.git
* [new branch] master -> master
6
2
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
6
2