Heroku Django deployment ModuleNotFoundError: No module named 'appointmentApp'
Heroku Django deployment ModuleNotFoundError: No module named 'appointmentApp'
我正在尝试使用 Heroku 部署一个 django 站点,当页面尝试加载时,我一直 运行 进入此错误
使用 heroku 日志 --tail
» Warning: heroku update available from 7.53.0 to 7.60.2.
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-05-18T01:09:37.493808+00:00 app[web.1]: worker.init_process()
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2022-05-18T01:09:37.493809+00:00 app[web.1]: self.load_wsgi()
2022-05-18T01:09:37.493809+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-05-18T01:09:37.493810+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.callable = self.load()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-05-18T01:09:37.493811+00:00 app[web.1]: return self.load_wsgiapp()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-05-18T01:09:37.493812+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-05-18T01:09:37.493812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2022-05-18T01:09:37.493812+00:00 app[web.1]: mod = importlib.import_module(module)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493813+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "/app/GroomingService/GroomingService/wsgi.py", line 16, in <module>
2022-05-18T01:09:37.493816+00:00 app[web.1]: application = get_wsgi_application()
2022-05-18T01:09:37.493816+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2022-05-18T01:09:37.493816+00:00 app[web.1]: django.setup(set_prefix=False)
2022-05-18T01:09:37.493817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
2022-05-18T01:09:37.493817+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
2022-05-18T01:09:37.493818+00:00 app[web.1]: app_config = AppConfig.create(entry)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/config.py", line 223, in create
2022-05-18T01:09:37.493819+00:00 app[web.1]: import_module(entry)
2022-05-18T01:09:37.493819+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493819+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
2022-05-18T01:09:37.493884+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [10] [INFO] Worker exiting (pid: 10)
2022-05-18T01:09:37.493951+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [9] [INFO] Worker exiting (pid: 9)
2022-05-18T01:09:37.553717+00:00 heroku[web.1]: State changed from starting to up
2022-05-18T01:09:37.553815+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.553820+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 209, in run
2022-05-18T01:09:37.554025+00:00 app[web.1]: self.sleep()
2022-05-18T01:09:37.554037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-05-18T01:09:37.554155+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-05-18T01:09:37.554157+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.554242+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.554243+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.554366+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554413+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554415+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554423+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 642, in kill_worker
2022-05-18T01:09:37.554565+00:00 app[web.1]: os.kill(pid, sig)
2022-05-18T01:09:37.554588+00:00 app[web.1]: ProcessLookupError: [Errno 3] No such process
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554590+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554591+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554600+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-05-18T01:09:37.554663+00:00 app[web.1]: sys.exit(run())
2022-05-18T01:09:37.554671+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2022-05-18T01:09:37.554736+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-05-18T01:09:37.554743+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 231, in run
2022-05-18T01:09:37.554825+00:00 app[web.1]: super().run()
2022-05-18T01:09:37.554833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
2022-05-18T01:09:37.554896+00:00 app[web.1]: Arbiter(self).run()
2022-05-18T01:09:37.554897+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 229, in run
2022-05-18T01:09:37.554979+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-05-18T01:09:37.554981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-05-18T01:09:37.555076+00:00 app[web.1]: self.stop()
2022-05-18T01:09:37.555084+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 390, in stop
2022-05-18T01:09:37.555186+00:00 app[web.1]: self.kill_workers(sig)
2022-05-18T01:09:37.555187+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 632, in kill_workers
2022-05-18T01:09:37.555323+00:00 app[web.1]: self.kill_worker(pid, sig)
2022-05-18T01:09:37.555325+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 644, in kill_worker
2022-05-18T01:09:37.555460+00:00 app[web.1]: if e.errno == errno.ESRCH:
2022-05-18T01:09:37.555462+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.555542+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.555551+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.555663+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.555693+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.697703+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T01:09:37.764077+00:00 heroku[web.1]: State changed from up to crashed
2022-05-18T01:09:51.528658+00:00 app[api]: Set maintenance mode off by user danccoral@hotmail.com
2022-05-18T01:10:13.487012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=3f02a257-18d8-438d-bcac-778254354ad4 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:14.027724+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=f61fe659-2371-48f5-9c94-87339a85b363 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.138152+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=4ef2c6f9-ef8b-4798-a310-8c76e305d2eb fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.502227+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=84e71487-1c60-4024-b27f-37f24a8bf6c6 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:12:44.961980+00:00 app[api]: Starting process with command `printenv` by user danccoral@hotmail.com
2022-05-18T01:12:51.062148+00:00 heroku[run.5944]: Awaiting client
2022-05-18T01:12:51.079149+00:00 heroku[run.5944]: Starting process with command `printenv`
2022-05-18T01:12:51.186266+00:00 heroku[run.5944]: State changed from starting to up
2022-05-18T01:12:54.516779+00:00 heroku[run.5944]: Process exited with status 0
2022-05-18T01:12:54.655109+00:00 heroku[run.5944]: State changed from up to complete
2022-05-18T01:31:48.081568+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=a13a7884-78a3-461e-be0e-f047d101ffd3 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:31:48.450104+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=9473141e-ed72-4fb5-8c9b-9264f9b7f42f fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
我能从这个错误列表中找到的两个最值得注意的事情是
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
和
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
我知道错误 H10 可能是我的 procfile 有问题
web: gunicorn GroomingService.GroomingService.wsgi
我的项目文件结构
Project/
GroomingService/
accountApp/
adminApp/
appointmentApp/
GroomingService/
__pycache__
_init_.py
asagi.py
settings.py
urls.py
views.py
wsgi.py
loginApp/
static/
staticfiles/
templates/
.env
.gitattributes
Procfile
README.md
requirements.txt
runtime.txt
早些时候我也遇到了麻烦,因为它告诉我
找不到 wsgi
No module named 'GroomingService.wsgi'
然后找不到该设置
因此,我在文件路径中添加了一个额外的 GroomingService,以便它可以在我的 Procfile 和我的 wsgifile
中找到它
#wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GroomingService.GroomingService.settings')
application = get_wsgi_application()
proc文件
web: gunicorn GroomingService.GroomingService.wsgi
requirements.txt
asgiref==3.5.0
dj-database-url==0.5.0
Django==4.0.1
django-activeurl==0.2.0
django-appconf==1.0.5
django-classy-tags==3.0.1
django-crispy-forms==1.14.0
django-environ==0.8.1
django-heroku==0.3.1
gunicorn==20.1.0
lxml==4.8.0
psycopg2==2.9.3
python-decouple==3.6
python-dotenv==0.20.0
sqlparse==0.4.2
tzdata==2021.5
whitenoise==6.1.0
runtime.txt
python-3.9.12
编辑:
settings.py
from pathlib import Path
import os
from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['elizabethselegantdoggrooming.herokuapp.com/', '127.0.0.1', 'elizabethselegantdoggrooming.com']
#is used for crispyforms?
CRISPY_TEMPLATE_PACK = 'bootstrap5'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#django apps
'crispy_forms',
'appointmentApp',
'loginApp',
'accountApp',
'adminApp',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'GroomingService.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'GroomingService.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Los_Angeles'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = 'static/'
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#csrf
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
如何引导它找到模块?
检查您的 settings.py 文件,您可能没有在 INSTALLED_APPS
部分注册该应用程序。
我不得不回溯,如果其他人遇到这个问题,您可能遇到同样的问题
基本上就是这样
文件结构错误 manage.py 必须位于项目的根目录,Procfile 和 requirements.txt 所在的位置,但如果无法更改,则可以更改 proc 文件
旧的 procfile
web: gunicorn GroomingService.GroomingService.wsgi
新的过程文件
web: gunicorn --pythonpath GroomingService GroomingService.wsgi
我正在尝试使用 Heroku 部署一个 django 站点,当页面尝试加载时,我一直 运行 进入此错误 使用 heroku 日志 --tail
» Warning: heroku update available from 7.53.0 to 7.60.2.
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-05-18T01:09:37.493808+00:00 app[web.1]: worker.init_process()
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2022-05-18T01:09:37.493809+00:00 app[web.1]: self.load_wsgi()
2022-05-18T01:09:37.493809+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-05-18T01:09:37.493810+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.callable = self.load()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-05-18T01:09:37.493811+00:00 app[web.1]: return self.load_wsgiapp()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-05-18T01:09:37.493812+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-05-18T01:09:37.493812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2022-05-18T01:09:37.493812+00:00 app[web.1]: mod = importlib.import_module(module)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493813+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "/app/GroomingService/GroomingService/wsgi.py", line 16, in <module>
2022-05-18T01:09:37.493816+00:00 app[web.1]: application = get_wsgi_application()
2022-05-18T01:09:37.493816+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2022-05-18T01:09:37.493816+00:00 app[web.1]: django.setup(set_prefix=False)
2022-05-18T01:09:37.493817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
2022-05-18T01:09:37.493817+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
2022-05-18T01:09:37.493818+00:00 app[web.1]: app_config = AppConfig.create(entry)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/config.py", line 223, in create
2022-05-18T01:09:37.493819+00:00 app[web.1]: import_module(entry)
2022-05-18T01:09:37.493819+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493819+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
2022-05-18T01:09:37.493884+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [10] [INFO] Worker exiting (pid: 10)
2022-05-18T01:09:37.493951+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [9] [INFO] Worker exiting (pid: 9)
2022-05-18T01:09:37.553717+00:00 heroku[web.1]: State changed from starting to up
2022-05-18T01:09:37.553815+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.553820+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 209, in run
2022-05-18T01:09:37.554025+00:00 app[web.1]: self.sleep()
2022-05-18T01:09:37.554037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-05-18T01:09:37.554155+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-05-18T01:09:37.554157+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.554242+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.554243+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.554366+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554413+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554415+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554423+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 642, in kill_worker
2022-05-18T01:09:37.554565+00:00 app[web.1]: os.kill(pid, sig)
2022-05-18T01:09:37.554588+00:00 app[web.1]: ProcessLookupError: [Errno 3] No such process
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554590+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554591+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554600+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-05-18T01:09:37.554663+00:00 app[web.1]: sys.exit(run())
2022-05-18T01:09:37.554671+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2022-05-18T01:09:37.554736+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-05-18T01:09:37.554743+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 231, in run
2022-05-18T01:09:37.554825+00:00 app[web.1]: super().run()
2022-05-18T01:09:37.554833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
2022-05-18T01:09:37.554896+00:00 app[web.1]: Arbiter(self).run()
2022-05-18T01:09:37.554897+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 229, in run
2022-05-18T01:09:37.554979+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-05-18T01:09:37.554981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-05-18T01:09:37.555076+00:00 app[web.1]: self.stop()
2022-05-18T01:09:37.555084+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 390, in stop
2022-05-18T01:09:37.555186+00:00 app[web.1]: self.kill_workers(sig)
2022-05-18T01:09:37.555187+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 632, in kill_workers
2022-05-18T01:09:37.555323+00:00 app[web.1]: self.kill_worker(pid, sig)
2022-05-18T01:09:37.555325+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 644, in kill_worker
2022-05-18T01:09:37.555460+00:00 app[web.1]: if e.errno == errno.ESRCH:
2022-05-18T01:09:37.555462+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.555542+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.555551+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.555663+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.555693+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.697703+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T01:09:37.764077+00:00 heroku[web.1]: State changed from up to crashed
2022-05-18T01:09:51.528658+00:00 app[api]: Set maintenance mode off by user danccoral@hotmail.com
2022-05-18T01:10:13.487012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=3f02a257-18d8-438d-bcac-778254354ad4 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:14.027724+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=f61fe659-2371-48f5-9c94-87339a85b363 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.138152+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=4ef2c6f9-ef8b-4798-a310-8c76e305d2eb fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.502227+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=84e71487-1c60-4024-b27f-37f24a8bf6c6 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:12:44.961980+00:00 app[api]: Starting process with command `printenv` by user danccoral@hotmail.com
2022-05-18T01:12:51.062148+00:00 heroku[run.5944]: Awaiting client
2022-05-18T01:12:51.079149+00:00 heroku[run.5944]: Starting process with command `printenv`
2022-05-18T01:12:51.186266+00:00 heroku[run.5944]: State changed from starting to up
2022-05-18T01:12:54.516779+00:00 heroku[run.5944]: Process exited with status 0
2022-05-18T01:12:54.655109+00:00 heroku[run.5944]: State changed from up to complete
2022-05-18T01:31:48.081568+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=a13a7884-78a3-461e-be0e-f047d101ffd3 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:31:48.450104+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=9473141e-ed72-4fb5-8c9b-9264f9b7f42f fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
我能从这个错误列表中找到的两个最值得注意的事情是
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
和
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
我知道错误 H10 可能是我的 procfile 有问题
web: gunicorn GroomingService.GroomingService.wsgi
我的项目文件结构
Project/
GroomingService/
accountApp/
adminApp/
appointmentApp/
GroomingService/
__pycache__
_init_.py
asagi.py
settings.py
urls.py
views.py
wsgi.py
loginApp/
static/
staticfiles/
templates/
.env
.gitattributes
Procfile
README.md
requirements.txt
runtime.txt
早些时候我也遇到了麻烦,因为它告诉我 找不到 wsgi
No module named 'GroomingService.wsgi'
然后找不到该设置 因此,我在文件路径中添加了一个额外的 GroomingService,以便它可以在我的 Procfile 和我的 wsgifile
中找到它#wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GroomingService.GroomingService.settings')
application = get_wsgi_application()
proc文件
web: gunicorn GroomingService.GroomingService.wsgi
requirements.txt
asgiref==3.5.0
dj-database-url==0.5.0
Django==4.0.1
django-activeurl==0.2.0
django-appconf==1.0.5
django-classy-tags==3.0.1
django-crispy-forms==1.14.0
django-environ==0.8.1
django-heroku==0.3.1
gunicorn==20.1.0
lxml==4.8.0
psycopg2==2.9.3
python-decouple==3.6
python-dotenv==0.20.0
sqlparse==0.4.2
tzdata==2021.5
whitenoise==6.1.0
runtime.txt
python-3.9.12
编辑: settings.py
from pathlib import Path
import os
from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['elizabethselegantdoggrooming.herokuapp.com/', '127.0.0.1', 'elizabethselegantdoggrooming.com']
#is used for crispyforms?
CRISPY_TEMPLATE_PACK = 'bootstrap5'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#django apps
'crispy_forms',
'appointmentApp',
'loginApp',
'accountApp',
'adminApp',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'GroomingService.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'GroomingService.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Los_Angeles'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = 'static/'
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#csrf
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
如何引导它找到模块?
检查您的 settings.py 文件,您可能没有在 INSTALLED_APPS
部分注册该应用程序。
我不得不回溯,如果其他人遇到这个问题,您可能遇到同样的问题
基本上就是这样
文件结构错误 manage.py 必须位于项目的根目录,Procfile 和 requirements.txt 所在的位置,但如果无法更改,则可以更改 proc 文件
旧的 procfile
web: gunicorn GroomingService.GroomingService.wsgi
新的过程文件
web: gunicorn --pythonpath GroomingService GroomingService.wsgi