[英]Deploying Django project on Heroku: ModuleNotFoundError
No where in my project do I import users.我没有在我的项目中导入用户。 Every single aspect of the project runs locally.
项目的每个方面都在本地运行。 I am using visual studio for my project.
我正在为我的项目使用 Visual Studio。
In my Project Directory在我的项目目录中
Settings.py INSTALLED_APPS = Settings.py INSTALLED_APPS =
# Add your apps here to enable them
'users.apps.usersConfig',
'resume.apps.resumeConfig',
'MainApp.apps.MainAppConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
Procfile:简介:
web: gunicorn Project.Project.wsgi:application
Here is the error这是错误
2020-08-16T06:35:31.691841+00:00 app[web.1]: Traceback (most recent call last):
2020-08-16T06:35:31.691846+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-08-16T06:35:31.691850+00:00 app[web.1]: worker.init_process()
2020-08-16T06:35:31.691851+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 129, in init_process
2020-08-16T06:35:31.691852+00:00 app[web.1]: self.load_wsgi()
2020-08-16T06:35:31.691852+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2020-08-16T06:35:31.691852+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-08-16T06:35:31.691857+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-08-16T06:35:31.691857+00:00 app[web.1]: self.callable = self.load()
2020-08-16T06:35:31.691858+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2020-08-16T06:35:31.691858+00:00 app[web.1]: return self.load_wsgiapp()
2020-08-16T06:35:31.691858+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2020-08-16T06:35:31.691859+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-08-16T06:35:31.691859+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 350, in import_app
2020-08-16T06:35:31.691859+00:00 app[web.1]: __import__(module)
2020-08-16T06:35:31.691861+00:00 app[web.1]: File "/app/Project/Project/wsgi.py", line 29, in <module>
2020-08-16T06:35:31.691861+00:00 app[web.1]: application = get_wsgi_application()
2020-08-16T06:35:31.691861+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-08-16T06:35:31.691862+00:00 app[web.1]: django.setup(set_prefix=False)
2020-08-16T06:35:31.691862+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
2020-08-16T06:35:31.691863+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2020-08-16T06:35:31.691863+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
2020-08-16T06:35:31.691863+00:00 app[web.1]: app_config = AppConfig.create(entry)
2020-08-16T06:35:31.691864+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/config.py", line 116, in create
2020-08-16T06:35:31.691864+00:00 app[web.1]: mod = import_module(mod_path)
2020-08-16T06:35:31.691864+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-08-16T06:35:31.691865+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-08-16T06:35:31.691865+00:00 app[web.1]: ModuleNotFoundError: No module named 'users'
I think that the reason for the import error is that the users.apps.usersConfig
entry (as well as the rest of them) on your INSTALLED_APPS
list will get imported at runtime.我认为导入错误的原因是
INSTALLED_APPS
列表中的users.apps.usersConfig
条目(以及其余条目)将在运行时导入。 As per Heroku's documentation , your issue might be the syntax of your Procfile.根据 Heroku 的 文档,您的问题可能是 Procfile 的语法。 Perhaps try the following:
也许尝试以下方法:
web: gunicorn Project.wsgi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.