自作アプリをHerokuにデプロイしようとしたらModuleNotFoundError
Python/Djangoベースで、Webアプリを作っています。
Herokuにデプロイしようとしたところ、エラーになってしまい動きません。
エラー文(heroku logs --tailの出力結果)
Console
12019-10-15T03:31:42.442488+00:00 app[web.1]: [2019-10-15 03:31:42 +0000] [10] [ERROR] Exception in worker process2019-10-15T03:31:42.442512+00:00 app[web.1]: Traceback (most recent call last): 22019-10-15T03:31:42.442515+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 32019-10-15T03:31:42.442518+00:00 app[web.1]: worker.init_process() 42019-10-15T03:31:42.44252+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process 52019-10-15T03:31:42.442522+00:00 app[web.1]: self.load_wsgi() 62019-10-15T03:31:42.442524+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi 72019-10-15T03:31:42.442526+00:00 app[web.1]: self.wsgi = self.app.wsgi() 82019-10-15T03:31:42.442528+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 92019-10-15T03:31:42.44253+00:00 app[web.1]: self.callable = self.load() 102019-10-15T03:31:42.442533+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 112019-10-15T03:31:42.442535+00:00 app[web.1]: return self.load_wsgiapp() 122019-10-15T03:31:42.442537+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 132019-10-15T03:31:42.442539+00:00 app[web.1]: return util.import_app(self.app_uri) 142019-10-15T03:31:42.442541+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 152019-10-15T03:31:42.442543+00:00 app[web.1]: __import__(module) 162019-10-15T03:31:42.442546+00:00 app[web.1]: File "/app/config/wsgi.py", line 16, in <module> 172019-10-15T03:31:42.442547+00:00 app[web.1]: application = get_wsgi_application() 182019-10-15T03:31:42.442549+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 192019-10-15T03:31:42.442551+00:00 app[web.1]: django.setup(set_prefix=False) 202019-10-15T03:31:42.442553+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 19, in setup 212019-10-15T03:31:42.442555+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 222019-10-15T03:31:42.442557+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ 232019-10-15T03:31:42.442559+00:00 app[web.1]: self._setup(name) 242019-10-15T03:31:42.44256+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 43, in _setup 252019-10-15T03:31:42.442562+00:00 app[web.1]: self._wrapped = Settings(settings_module) 262019-10-15T03:31:42.442564+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 106, in __init__ 272019-10-15T03:31:42.442566+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE) 282019-10-15T03:31:42.442568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module 292019-10-15T03:31:42.44257+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 302019-10-15T03:31:42.442572+00:00 app[web.1]: File "/app/config/settings.py", line 14, in <module> 312019-10-15T03:31:42.442574+00:00 app[web.1]: import dj_database_url 322019-10-15T03:31:42.442576+00:00 app[web.1]: ModuleNotFoundError: No module named 'dj_database_url' 332019-10-15T03:31:42.442735+00:00 app[web.1]: [2019-10-15 03:31:42 +0000] [10] [INFO] Worker exiting (pid: 10) 342019-10-15T03:31:42.443744+00:00 app[web.1]: [2019-10-15 03:31:42 +0000] [11] [ERROR] Exception in worker process2019-10-15T03:31:42.443748+00:00 app[web.1]: Traceback (most recent call last): 352019-10-15T03:31:42.44375+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 362019-10-15T03:31:42.443753+00:00 app[web.1]: worker.init_process() 372019-10-15T03:31:42.443755+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process 382019-10-15T03:31:42.443757+00:00 app[web.1]: self.load_wsgi() 392019-10-15T03:31:42.443759+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi 402019-10-15T03:31:42.443761+00:00 app[web.1]: self.wsgi = self.app.wsgi() 412019-10-15T03:31:42.443763+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 422019-10-15T03:31:42.443765+00:00 app[web.1]: self.callable = self.load() 432019-10-15T03:31:42.443767+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 442019-10-15T03:31:42.443769+00:00 app[web.1]: return self.load_wsgiapp() 452019-10-15T03:31:42.443771+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 462019-10-15T03:31:42.443773+00:00 app[web.1]: return util.import_app(self.app_uri) 472019-10-15T03:31:42.443775+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 482019-10-15T03:31:42.443777+00:00 app[web.1]: __import__(module) 492019-10-15T03:31:42.44378+00:00 app[web.1]: File "/app/config/wsgi.py", line 16, in <module> 502019-10-15T03:31:42.443782+00:00 app[web.1]: application = get_wsgi_application() 512019-10-15T03:31:42.443784+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 522019-10-15T06:33:47.825656+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=table--planner.herokuapp.com request_id=beca5a74-1fd7-4e79-9dba-57ac43d5db2d fwd="121.103.228.17" dyno= connect= service= status=503 bytes= protocol=https 532019-10-15T06:33:49.26447+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=table--planner.herokuapp.com request_id=c586f3f4-80ae-4a47-933a-4ffecbb8710a fwd="121.103.228.17" dyno= connect= service= status=503 bytes= protocol=https 54
上記の内、ここのせいだと思っているのですが、
Console
12019-10-15T03:31:42.442572+00:00 app[web.1]: File "/app/config/settings.py", line 14, in <module> 22019-10-15T03:31:42.442574+00:00 app[web.1]: import dj_database_url 32019-10-15T03:31:42.442576+00:00 app[web.1]: ModuleNotFoundError: No module named 'dj_database_url'
settings.pyのimport文に誤字のある様子もなく、
settings.py
python
1import os 2import dj_database_url 3 4#以下略
また、requirements.txtにも、ちゃんと書いてあります。
requirements.txt
txt
1astroid==2.3.1 2certifi==2019.9.11 3chardet==3.0.4 4colorama==0.4.1 5dj-database-url==0.5.0 #この通り、書いてはあるんです。 6Django==2.0.6 7django-heroku==0.3.1 8gunicorn==19.8.1 9heroku==0.1.4 10idna==2.8 11isort==4.3.21 12lazy-object-proxy==1.4.2 13mccabe==0.6.1 14psycopg2==2.8.3 15pylint==2.4.2 16python-dateutil==1.5 17pytz==2019.3 18requests==2.22.0 19six==1.12.0 20typed-ast==1.4.0 21urllib3==1.25.6 22whitenoise==4.1.4 23wrapt==1.11.2
ググって出てくるのは、「ちゃんとrequirements.txtに書いた??」ばかりだったので、他に思い当たる原因もなく行き詰まってしまい、質問投稿をさせていただきました。
なお、GitのCommitミスも考慮の上、git pull origin masterからの再修正・再デプロイを何度か試してみたのですが、関係はありませんでした。
また、開発環境は以下の通りです。
言語:python3.7.4
フレームワーク:django 2.0.6
ブラウザ:Google Chrome 77
エディタ:visual studio code 1.38
OS:Windows10 home
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/10/15 10:53
2019/10/16 06:26