Heroku 部署错误:无模块错误并返回 self.load_wsgiapp()

问题描述 投票:0回答:1

我使用 Python 3.12 制作了一个项目并让它在本地工作。现在我尝试将它部署在 Heroku 上,尽管我已经安装了所有要求,但它还是给出了这一点。它还说找不到名为 config 的模块。

2024-04-06T17:14:44.801570+00:00 app[web.1]: return self.load_wsgiapp()
2024-04-06T17:14:44.801570+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.801570+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2024-04-06T17:14:44.801571+00:00 app[web.1]: return util.import_app(self.app_uri)
2024-04-06T17:14:44.801571+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.801571+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
2024-04-06T17:14:44.801571+00:00 app[web.1]: mod = importlib.import_module(module)
2024-04-06T17:14:44.801572+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.801572+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-04-06T17:14:44.801573+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2024-04-06T17:14:44.801573+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.801574+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-04-06T17:14:44.801574+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-04-06T17:14:44.801574+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2024-04-06T17:14:44.801575+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2024-04-06T17:14:44.801575+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 995, in exec_module
2024-04-06T17:14:44.801575+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-04-06T17:14:44.801575+00:00 app[web.1]: File "/app/run.py", line 1, in <module>
2024-04-06T17:14:44.801575+00:00 app[web.1]: from project import app
2024-04-06T17:14:44.801576+00:00 app[web.1]: File "/app/project/__init__.py", line 9, in <module>
2024-04-06T17:14:44.801576+00:00 app[web.1]: from config import Config
2024-04-06T17:14:44.801576+00:00 app[web.1]: ModuleNotFoundError: No module named 'config'
2024-04-06T17:14:44.801637+00:00 app[web.1]: [2024-04-06 17:14:44 +0000] [10] [INFO] Worker exiting (pid: 10)
2024-04-06T17:14:44.802387+00:00 app[web.1]: [2024-04-06 17:14:44 +0000] [9] [ERROR] Exception in worker process
2024-04-06T17:14:44.802388+00:00 app[web.1]: Traceback (most recent call last):
2024-04-06T17:14:44.802389+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
2024-04-06T17:14:44.802390+00:00 app[web.1]: worker.init_process()
2024-04-06T17:14:44.802390+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
2024-04-06T17:14:44.802391+00:00 app[web.1]: self.load_wsgi()
2024-04-06T17:14:44.802391+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2024-04-06T17:14:44.802392+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2024-04-06T17:14:44.802392+00:00 app[web.1]: ^^^^^^^^^^^^^^^
2024-04-06T17:14:44.802392+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
2024-04-06T17:14:44.802392+00:00 app[web.1]: self.callable = self.load()
2024-04-06T17:14:44.802393+00:00 app[web.1]: ^^^^^^^^^^^
2024-04-06T17:14:44.802396+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2024-04-06T17:14:44.802397+00:00 app[web.1]: return self.load_wsgiapp()
2024-04-06T17:14:44.802397+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.802397+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2024-04-06T17:14:44.802398+00:00 app[web.1]: return util.import_app(self.app_uri)
2024-04-06T17:14:44.802398+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.802398+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
2024-04-06T17:14:44.802399+00:00 app[web.1]: mod = importlib.import_module(module)
2024-04-06T17:14:44.802399+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.802400+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-04-06T17:14:44.802400+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2024-04-06T17:14:44.802401+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.802401+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-04-06T17:14:44.802401+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-04-06T17:14:44.802402+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2024-04-06T17:14:44.802402+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2024-04-06T17:14:44.802402+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 995, in exec_module
2024-04-06T17:14:44.802402+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-04-06T17:14:44.802403+00:00 app[web.1]: File "/app/run.py", line 1, in <module>
2024-04-06T17:14:44.802403+00:00 app[web.1]: from project import app
2024-04-06T17:14:44.802403+00:00 app[web.1]: File "/app/project/__init__.py", line 9, in <module>
2024-04-06T17:14:44.802403+00:00 app[web.1]: from config import Config
2024-04-06T17:14:44.802403+00:00 app[web.1]: ModuleNotFoundError: No module named 'config'
2024-04-06T17:14:44.802492+00:00 app[web.1]: [2024-04-06 17:14:44 +0000] [9] [INFO] Worker exiting (pid: 9)
2024-04-06T17:14:44.867001+00:00 app[web.1]: [2024-04-06 17:14:44 +0000] [2] [ERROR] Worker (pid:9) exited with code 3
2024-04-06T17:14:44.870389+00:00 app[web.1]: [2024-04-06 17:14:44 +0000] [2] [ERROR] Worker (pid:10) exited with code 3
2024-04-06T17:14:44.870435+00:00 app[web.1]: Traceback (most recent call last):
2024-04-06T17:14:44.870437+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 209, in run
2024-04-06T17:14:44.870661+00:00 app[web.1]: self.sleep()
2024-04-06T17:14:44.870698+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 360, in sleep
2024-04-06T17:14:44.870802+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2024-04-06T17:14:44.870966+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-06T17:14:44.870976+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2024-04-06T17:14:44.871052+00:00 app[web.1]: self.reap_workers()
2024-04-06T17:14:44.871077+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
2024-04-06T17:14:44.871180+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2024-04-06T17:14:44.871223+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2024-04-06T17:14:44.871228+00:00 app[web.1]:
2024-04-06T17:14:44.871247+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2024-04-06T17:14:44.871247+00:00 app[web.1]:
2024-04-06T17:14:44.871247+00:00 app[web.1]: Traceback (most recent call last):
2024-04-06T17:14:44.871248+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2024-04-06T17:14:44.871353+00:00 app[web.1]: sys.exit(run())
2024-04-06T17:14:44.871407+00:00 app[web.1]: ^^^^^
2024-04-06T17:14:44.871419+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2024-04-06T17:14:44.871520+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2024-04-06T17:14:44.871568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/base.py", line 236, in run
2024-04-06T17:14:44.871694+00:00 app[web.1]: super().run()
2024-04-06T17:14:44.871714+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/base.py", line 72, in run
2024-04-06T17:14:44.871769+00:00 app[web.1]: Arbiter(self).run()
2024-04-06T17:14:44.871791+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 229, in run
2024-04-06T17:14:44.871875+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2024-04-06T17:14:44.871908+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 342, in halt
2024-04-06T17:14:44.871995+00:00 app[web.1]: self.stop()
2024-04-06T17:14:44.872013+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 396, in stop
2024-04-06T17:14:44.872098+00:00 app[web.1]: time.sleep(0.1)
2024-04-06T17:14:44.872117+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2024-04-06T17:14:44.872182+00:00 app[web.1]: self.reap_workers()
2024-04-06T17:14:44.872199+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
2024-04-06T17:14:44.872299+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2024-04-06T17:14:44.872330+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2024-04-06T17:14:44.948062+00:00 heroku[web.1]: Process exited with status 1
2024-04-06T17:14:44.971192+00:00 heroku[web.1]: State changed from up to crashed

我试图在 Heroku 上运行我的网站,但它给了我模块导入错误。我不知道去哪里看。

python heroku module config
1个回答
0
投票

谢谢您的帮助。我已经设法解决这个问题。这与未安装某些依赖项有关。另外,在将我的requirements.txt部署到Heroku之前,我没有使用

pip freeze > requirements.txt
更新它。

© www.soinside.com 2019 - 2024. All rights reserved.