简体   繁体   中英

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.

In my Project Directory

在此处输入图片说明

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. As per Heroku's documentation , your issue might be the syntax of your Procfile. Perhaps try the following:

web: gunicorn Project.wsgi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM