未找到模块错误:没有名为'django_app'的模块具有heroku部署

whhtz7ly  于 2022-11-13  发布在  Go
关注(0)|答案(1)|浏览(147)

Hey mentors and senior devs I am now on this issue 5-7 hours trying to solve it, This issue happens during the deployment of my app on digital oceans apps and these are logs that Heroku sent please help me figure it out

2022-10-03T10:37:01.047248352Z [2022-10-03 10:37:01 +0000] [1] [INFO] Starting gunicorn 20.1.0
2022-10-03T10:37:01.048342704Z [2022-10-03 10:37:01 +0000] [1] [INFO] Listening at: 
http://0.0.0.0:8080 (1)
2022-10-03T10:37:01.048420287Z [2022-10-03 10:37:01 +0000] [1] [INFO] Using worker: sync
2022-10-03T10:37:01.105225067Z [2022-10-03 10:37:01 +0000] [16] [INFO] Booting worker with 
pid: 16
2022-10-03T10:37:01.121367774Z [2022-10-03 10:37:01 +0000] [16] [ERROR] Exception in worker 
process
2022-10-03T10:37:01.121405181Z Traceback (most recent call last):
2022-10-03T10:37:01.121410503Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-10-03T10:37:01.121414404Z     worker.init_process()
2022-10-03T10:37:01.121419137Z   File "/workspace/.heroku/python/lib/python3.10/site-``` 
packages/gunicorn/workers/base.py", line 134, in init_process
2022-10-03T10:37:01.121423724Z     self.load_wsgi()
2022-10-03T10:37:01.121428153Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-10-03T10:37:01.121431187Z     self.wsgi = self.app.wsgi()
2022-10-03T10:37:01.121434180Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/app/base.py", line 67, in wsgi
2022-10-03T10:37:01.121438157Z     self.callable = self.load()
2022-10-03T10:37:01.121441663Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-10-03T10:37:01.121462270Z     return self.load_wsgiapp()
2022-10-03T10:37:01.121465690Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-10-03T10:37:01.121469061Z     return util.import_app(self.app_uri)
2022-10-03T10:37:01.121472387Z   File "/workspace/.heroku/python/lib/python3.10/site- 
packages/gunicorn/util.py", line 359, in import_app
2022-10-03T10:37:01.121475619Z     mod = importlib.import_module(module)
2022-10-03T10:37:01.121482753Z   File 
"/workspace/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-10-03T10:37:01.121486027Z     return _bootstrap._gcd_import(name[level:], package, level)
2022-10-03T10:37:01.121490349Z   File "<frozen importlib._bootstrap>", line 1050, in 
_gcd_import
2022-10-03T10:37:01.121493850Z   File "<frozen importlib._bootstrap>", line 1027, in 
_find_and_load
2022-10-03T10:37:01.121497304Z   File "<frozen importlib._bootstrap>", line 992, in

_find_and_load_unlocked 2022-10-03T10:37:01.121501773Z File "", line 241, in _call_with_frames_removed 2022-10-03T10:37:01.121505268Z File "", line 1050, in _gcd_import 2022-10-03T10:37:01.121508644Z File "", line 1027, in _find_and_load 2022-10-03T10:37:01.121511905Z File "", line 1004, in _find_and_load_unlocked 2022-10-03T10:37:01.121515248Z ModuleNotFoundError: No module named 'django_app' 2022-10-03T10:37:01.121731498Z [2022-10-03 10:37:01 +0000] [16] [INFO] Worker exiting (pid: 16) 2022-10-03T10:37:01.207224069Z [2022-10-03 10:37:01 +0000] [1] [INFO] Shutting down: Master 2022-10-03T10:37:01.207265202Z [2022-10-03 10:37:01 +0000] [1] [INFO] Reason: Worker failed to boot. 2022-10-03T10:37:04.348012028Z [2022-10-03 10:37:04 +0000] [1] [INFO] Starting gunicorn 20.1.0 2022-10-03T10:37:04.349215146Z [2022-10-03 10:37:04 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) 2022-10-03T10:37:04.349332842Z [2022-10-03 10:37:04 +0000] [1] [INFO] Using worker: sync 2022-10-03T10:37:04.391853564Z [2022-10-03 10:37:04 +0000] [16] [INFO] Booting worker with pid: 16 2022-10-03T10:37:04.406015762Z [2022-10-03 10:37:04 +0000] [16] [ERROR] Exception in worker process 2022-10-03T10:37:04.406048084Z Traceback (most recent call last): 2022-10-03T10:37:04.406055314Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/arbiter.py", line 589, in spawn_worker 2022-10-03T10:37:04.406060597Z worker.init_process() 2022-10-03T10:37:04.406066330Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/workers/base.py", line 134, in init_process 2022-10-03T10:37:04.406070425Z self.load_wsgi() 2022-10-03T10:37:04.406073524Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/workers/base.py", line 146, in load_wsgi 2022-10-03T10:37:04.406075830Z self.wsgi = self.app.wsgi() 2022-10-03T10:37:04.406078174Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/app/base.py", line 67, in wsgi 2022-10-03T10:37:04.406081378Z self.callable = self.load() 2022-10-03T10:37:04.406083592Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/app/wsgiapp.py", line 58, in load 2022-10-03T10:37:04.406085923Z return self.load_wsgiapp() 2022-10-03T10:37:04.406089029Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp 2022-10-03T10:37:04.406091677Z return util.import_app(self.app_uri) 2022-10-03T10:37:04.406093958Z File "/workspace/.heroku/python/lib/python3.10/site- packages/gunicorn/util.py", line 359, in import_app 2022-10-03T10:37:04.406096392Z mod = importlib.import_module(module) 2022-10-03T10:37:04.406101142Z File "/workspace/.heroku/python/lib/python3.10/importlib/init.py", line 126, in import_module 2022-10-03T10:37:04.406103341Z return _bootstrap._gcd_import(name[level:], package, level) 2022-10-03T10:37:04.406105924Z File "", line 1050, in _gcd_import 2022-10-03T10:37:04.406108164Z File "", line 1027, in _find_and_load 2022-10-03T10:37:04.406110635Z File "", line 992, in _find_and_load_unlocked 2022-10-03T10:37:04.406113766Z File "", line 241, in _call_with_frames_removed 2022-10-03T10:37:04.406116173Z File "", line 1050, in _gcd_import 2022-10-03T10:37:04.406118254Z File "", line 1027, in _find_and_load 2022-10-03T10:37:04.406120822Z File "", line 1004, in _find_and_load_unlocked 2022-10-03T10:37:04.406122832Z ModuleNotFoundError: No module named 'django_app' 2022-10-03T10:37:04.406270392Z [2022-10-03 10:37:04 +0000] [16] [INFO] Worker exiting (pid: 16) 2022-10-03T10:37:04.482169771Z [2022-10-03 10:37:04 +0000] [1] [INFO] Shutting down: Master 2022-10-03T10:37:04.482261239Z [2022-10-03 10:37:04 +0000] [1] [INFO] Reason: Worker failed to boot.

in my requirements.txt

    asgiref==3.4.1
beautifulsoup4==4.11.1
binary==1.0.0
dj-database-url==1.0.0
Django==3.2.15
django-bootstrap-v5==1.0.11
django-crispy-forms==1.13.0
django-heroku==0.3.1
django-request==1.6.1
gunicorn==20.1.0
importlib-metadata==4.8.3
Pillow==8.4.0
psycopg2==2.9.3
psycopg2-binary==2.9.3
python-dateutil==2.8.2
pytz==2022.2.1
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.2
typing-extensions==4.1.1
whitenoise==5.3.0
zipp==3.6.0

settings

    """
from django.core.management.utils import get_random_secret_key
from pathlib import Path
import os
import sys
import dj_database_url

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", get_random_secret_key())

# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False
DEBUG = os.getenv("DEBUG", "False") == "True"

ALLOWED_HOSTS = ['cajetan.global', 'www.cajetan.global']





# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
    'users',
    'blog',
    'memberships',
    'dashboard',
    'crispy_forms',
    'bootstrap5',

]

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',
]

ROOT_URLCONF = 'cajetanglobalvisas.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [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',
                'blog.context_processors.add_variable_to_context',
            ],
        },
    },
]

WSGI_APPLICATION = 'cajetanglobalvisas.wsgi.application'



DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"

if DEVELOPMENT_MODE is True:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.sqlite3",
            "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
        }
    }
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
    if os.getenv("DATABASE_URL", None) is None:
        raise Exception("DATABASE_URL environment variable not defined")
    DATABASES = {
        "default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
    }

# Password validation
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
# STATIC_URL = '/static/'
# STATIC_ROOT = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR/'static'),)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 587

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'users.User'

CRISPY_TEMPLATE_PACK= 'bootstrap4'

SITE_ID = 1

#change this in production
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = 'cajetanglobalvisa\messages'

# HTTPS settings
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True

# HSTS settings
SECURE_HSTS_SECONDS = 31536000 # 1 year
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
ymzxtsji

ymzxtsji1#

由于您尚未将应用程序添加到设置文件中的已安装应用程序中,因此出现“未找到模块”错误。
要添加,请执行以下操作:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
    'users',
    'django_app', #added here
    'blog',
    'memberships',
    'dashboard',
    'crispy_forms',
    'bootstrap5',

]

相关问题