LoginSignup
27

More than 3 years have passed since last update.

herokuで悩んだところ

Last updated at Posted at 2020-03-11

本記事について

こちらの記事を参考にherokuにpythonファイルをデプロイしました。途中でエラーが発生したため解決方法を記録します。

デプロイまでの流れ

  1. herokuのアカウント作成
  2. brewでHerokuCLIインストール
  3. $ heroku login
  4. $ heroku create <アプリの名前>
  5. requirements.txtに外部ライブラリを記載
    (デプロイ手順は作成したappのDeployページに書いてある)
  6. $ heroku git:clone -a <アプリの名前>
  7. $ cd <アプリの名前>
  8. $ git add .
  9. $ git commit -am "make it better"
  10. $ git push heroku master

ERROR

No default language could be detected for this app.


(venv) ~/p/post_notice_heroku (master|✔) $ git push heroku master
Counting objects: 33, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (33/33), 6.59 KiB | 844.00 KiB/s, done.
Total 33 (delta 12), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote:  !     No default language could be detected for this app.
remote:                         HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:                         See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
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'

ビルドパックの設定をする必要があるとのこと。
ここからpythonを選択。
$ heroku buildpacks:set heroku/pythonを実行


(venv) ~/p/post_notice_heroku (master|…) $ heroku buildpacks:set heroku/python
Buildpack set. Next release on <アプリ名> will use heroku/python.
Run git push heroku master to create a new release using this buildpack.

App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz


(venv) ~/p/post_notice_heroku (master|…) $ git push heroku master
Counting objects: 33, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (33/33), 6.59 KiB | 844.00 KiB/s, done.
Total 33 (delta 12), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
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'

これはpushするファイルの中にrequirements.txtを作成していないのが原因でした。
外部ライブラリはこちらのtxtファイルに記載する必要があるとのこと。

Please verify your account to install this add-on plan

venv) ~/p/post_notice_heroku (master|✔) $ heroku addons:add scheduler:standard
Creating scheduler:standard on ⬢ <アプリ名>... !
 ▸    Please verify your account to install this add-on plan (please enter a credit card) For more information, see
 ▸    https://devcenter.heroku.com/categories/billing Verify now at https://heroku.com/verify

これは、heroku上で定期的に実行してくれるheroku schedulerを導入するために$ heroku addons:create scheduler:standardを実行した時に発生。
heroku schedulerの利用にはクレカの登録が必要とのことです。

クレカ登録後、もう一度$ heroku addons:create scheduler:standardをすれば、コンソールから設定可能になります。

Couldn't find that app.

これはHerokuでいくつかのアプリを作成したり、削除したりしていた時に発生しました。

open .git/configを見てみると、

[remote "heroku"]
    url = https://git.heroku.com/<アプリ名>.git

この<アプリ名>の部分が、すでに削除したはずのアプリ名になっていたため、現在のアプリ名に直接書き換えて解決。

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
27