前提
Window環境で作成したアプリケーションを Heroku へデプロイしました。
本番環境でアプリケーションページへ遷移すると404エラーが発生してしまいます。
ローカル環境では問題なく処理できるのですが、本番環境だとエラーがでてしまい動作しませんでした。
画像のように Not Found となってしまいました。
実現したいこと
ここに実現したいことを箇条書きで書いてください。
アプリケーションを動作できるようにしたいです。
発生している問題・エラーメッセージ
アプリケーションログ
2022-07-17T11:40:57.931586+00:00 heroku[router]: at=info method=GET path="/" host=app.herokuapp.com request_id=b14646e6-e807-4ddc-a59c-835c15014d05 fwd="126.251.50.72" dyno=web.1 connect=0ms service=118ms status=404 bytes=411 protocol=https 2022-07-17T11:40:57.933032+00:00 app[web.1]: 10.1.63.232 - - [17/Jul/2022:20:40:57 +0900] "GET / HTTP/1.1" 404 179 "https://dashboard.heroku.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62"
git push heroku main の結果
Enumerating objects: 15, done. Counting objects: 100% (15/15), done. Delta compression using up to 4 threads Compressing objects: 100% (7/7), done. Writing objects: 100% (8/8), 818 bytes | 818.00 KiB/s, done. Total 8 (delta 5), reused 0 (delta 0), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Using buildpack: heroku/python remote: -----> Python app detected remote: -----> Using Python version specified in runtime.txt remote: -----> No change in requirements detected, installing from cache remote: -----> Using cached install of python-3.8.13 remote: -----> Installing pip 22.1.2, setuptools 60.10.0 and wheel 0.37.1 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Collecting setuptools==61.2.0 remote: Downloading setuptools-61.2.0-py3-none-any.whl (1.1 MB) remote: Installing collected packages: setuptools remote: Attempting uninstall: setuptools remote: Found existing installation: setuptools 60.10.0 remote: Uninstalling setuptools-60.10.0: remote: Successfully uninstalled setuptools-60.10.0 remote: Successfully installed setuptools-61.2.0 remote: -----> Skipping Django collectstatic since the env var DISABLE_COLLECTSTATIC is set. remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 63.8M remote: -----> Launching... remote: Released v12 remote: https://app.herokuapp.com/ deployed to Heroku remote: remote: This app is using the Heroku-20 stack, however a newer stack is available. remote: To upgrade to Heroku-22, see: remote: https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack remote: remote: Verifying deploy... done. To https://git.heroku.com/app.git 3c5974a..8406b1e main -> main
試したこと
Heroku stackを20から22にアップグレードしてみるため、アプリケーションをPython 3.9.13 で再作成。
その後、Heroku-22 stackに本番環境を指定した。本番環境でアプリケーションで動作させると、変わらず Not Found なった。
アプリケーションログ
2022-07-17T16:45:26.563028+00:00 heroku[router]: at=info method=GET path="/" host=ma-qwuchan.herokuapp.com request_id=c11ba0be-1ab3-4f9a-abaa-b2fb8dbb51cd fwd="126.251.50.72" dyno=web.1 connect=0ms service=11ms status=404 bytes=452 protocol=https 2022-07-17T16:45:26.562847+00:00 app[web.1]: 10.1.3.249 - - [18/Jul/2022:01:45:26 +0900] "GET / HTTP/1.1" 404 179 "https://dashboard.heroku.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62"
git push heroku main の結果
Enumerating objects: 112, done. Counting objects: 100% (112/112), done. Delta compression using up to 4 threads Compressing objects: 100% (99/99), done. Writing objects: 100% (112/112), 33.25 KiB | 1.96 MiB/s, done. Total 112 (delta 36), reused 0 (delta 0), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-22 stack remote: -----> Using buildpack: heroku/python 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: ! remote: ! ## Warning - The same version of this code has already been built: 30dbe438944d1004c01d5396fe49b6e01507e0bb remote: ! remote: ! We have detected that you have triggered a build from source code with version 30dbe438944d1004c01d5396fe49b6e01507e0bb remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. remote: ! remote: ! If you are developing on a branch and deploying via git you must run: remote: ! remote: ! git push heroku <branchname>:main remote: ! remote: ! This article goes into details on the behavior: remote: ! https://devcenter.heroku.com/articles/duplicate-build-version remote: remote: Verifying deploy... remote: remote: ! Push rejected to app. remote: To https://git.heroku.com/app.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/app.git'
「ビルドパックと互換性のないアプリ」と新しくエラーが見つかった。
しかし、heroku/python と正しいビルドパックが設定されている。
追記
・アプリを消去し、ビルドパックを heroku/python に設定後、再度アプリケーションを本番環境で動作させてみるが変わらず No Found になり、アプリケーションログ、git push heroku main の結果も変わらなかった。
・Pyhon buildpack(https://github.com/heroku/heroku-buildpack-python/blob/61609930c167e04ea4b41027e725ac46f7270e72/bin/detect)
によると、Python のプロジェクトかどうかは、requirements.txt、setup.py、Pipfile のどれかがあるかどうかで判定しているらしい。。 (runtime.txt に記載してるが、)
requirements.txt に Python のバージョンを記載後、デプロイ
ERROR: Could not find a version that satisfies the requirement python-3.9.13 (from versions: none) ERROR: No matching distribution found for python-3.9.13
とビルドエラーが返された。
・runtime.txt を消去、requirements.txt に Python のバージョンを記載後、デプロイすると、上記と同様のビルドエラーが返されました。
・runtime.txt はそのままで以下の Pipfile を追加後、デプロイ。本番環境で動作確認すると、No Found になり、アプリケーションログ、git push heroku main の結果も変わらなかった。
[[source]] url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" [packages] [dev-packages] [requires] python_version = "3.9.13"
補足情報(FW/ツールのバージョンなど)
【ローカル】
Python3.8.1 3⇒ Python 3.9.13
Heroku7.60.2
Windows home10
Git 2.36.1.
Sqlite3 3.36.0
【本番環境】
Heroku-20 stack ⇒ Heroku-22 stack

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。