LoginSignup
5
1

More than 1 year has passed since last update.

しばらくさぼっていたLINEBOTを久しぶりに動かした話

Last updated at Posted at 2022-02-28

だいぶ前に試してみたものに再度チャレンジしたら、バージョンが古くて振り回された。
ログが長い部分はほげほげしてます。

コマンドプロンプトからherokuログイン

コマンドプロンプト
$ heroku login
heroku: Press any key to open up the browser to login or q to exit:
ほげほげ
Logging in... done
Logged in as メールアドレス

先にHerokuアプリを作る

image.png
image.png

アプリへデプロイ

コマンドプロンプト
$ heroku git:remote -a アプリ名
set git remote heroku to https://git.heroku.com/アプリ名.git

$ git add .

$ git commit -m "コメント"
On branch master
nothing to commit, working tree clean

push失敗

PushFailed
$ git push heroku master
ほげほげ
remote:  !     Push rejected, failed to compile Python app.
remote:  !     Push failed
remote: Verifying deploy...
remote: !       Push rejected to アプリ名.
remote:
To https://git.heroku.com/アプリ名.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/アプリ名.git'

logを確認

heroku logs
$ heroku logs
ほげほげ
2022-02-28T12:55:40.000000+00:00 app[api]: Build failed -- check your build output: dashboard.herokuURL

アプリのActivityからも確認
image.png

どうやらpython-3.6.3は古いらしい。
他のライブラリに影響がでると嫌なので、とりあえず3.6で使えるやつにした。

runtime.txt
python-3.6.15

HerokuへPush

コマンドプロンプト
$ git add .
$ git commit -m "fix: python-version"
[master cced326] fix: python-version
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git push heroku master
Enumerating objects: 54, done.
Counting objects: 100% (54/54), done.
ほげほげ
remote: Verifying deploy... done.
To https://git.heroku.com/アプリ名.git
 * [new branch]      master -> master

JSONでエラー

500が返ってくる
$ heroku logs
ほげほげ
2022-02-28T13:05:37.103869+00:00 app[web.1]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-02-28T13:05:37.104156+00:00 app[web.1]: 10.1.91.183 - - [28/Feb/2022 13:05:37] "POST /callback HTTP/1.1" 500 -

line-bot-sdkが古いらしい

line-bot-sdkを最新にした

requirements.txt
line-bot-sdk==1.19.0

Pushする

コマンドプロンプト
$ git add .
$ git commit -m "fix: line-bot-sdkのversion変更"
[master 1db1bdf] fix: line-bot-sdkversion変更
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git push heroku master
ほげほげ
remote: Verifying deploy... done.
To https://git.heroku.com/アプリ名.git
   cced326..1db1bdf  master -> master

やっと動いた

image.png

古いアプリはバージョン確認が大事だねというお話。

参考

Heroku の Python サポート
herokuにデプロイする際に、エラーがでてしまう

5
1
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
1