简体   繁体   中英

Push rejected, failed to compile Python app on Heroku

I'm trying to deploy a Django app to Heroku, it starts to build, download and installs everything, but that's what I get when it comes to 'Collectstatic environment variables':

    ****** Collectstatic environment variables:
       PYTHONUNBUFFERED=1
       PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:/app/.heroku/python/lib/pkg-config:
       DEBUG_COLLECTSTATIC=1
       BPLOG_PREFIX=buildpack.python
       PWD=/tmp/build_5f41d4f4
       HOME=/app
       LANG=en_US.UTF-8
       SOURCE_VERSION=ff7fb8a801cfb1de3d7b84e14312dbe284946333
       REQUEST_ID=f6aa81af-75e0-afbc-a547-0f055efec989
       ENV_DIR=/tmp/d20220120-46-2ziyj3
       PYTHONPATH=.
       CPLUS_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:
       BIN_DIR=/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/bin
       LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:
       SHLVL=1
       LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:
       PIP_NO_PYTHON_VERSION_WARNING=1
       BUILDPACK_LOG_FILE=/dev/fd/3
       STACK=heroku-20
       BUILD_DIR=/tmp/build_5f41d4f4
       CACHE_DIR=/tmp/codon/tmp/cache
       PATH=/app/.heroku/python/bin:/app/.heroku/vendor/bin::/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/vendor/
       EXPORT_PATH=/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/bin/../export
       C_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:
       DYNO=run.3282
       PROFILE_PATH=/tmp/build_5f41d4f4/.profile.d/python.sh
       OLDPWD=/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136
       _=/usr/bin/env
 !     Push rejected, failed to compile Python app.
 !     Push failed

This is my settings.py file:

from pathlib import Path
import os

# 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 = '***'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['dwek-portfolio.herokuapp.com', '127.0.0.1']


# Application definition

INSTALLED_APPS = [
    'blog',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    '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 = 'my_site.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',
            ],
        },
    },
]

WSGI_APPLICATION = 'my_site.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 = 'UTC'

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 = [
    BASE_DIR / "static"
]

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MEDIA_ROOT = BASE_DIR / "uploads"
MEDIA_URL = "/uploads/"

I did not find anything about it on the internet and it is terribly frustrating. Thanks for the help!

I think it might be because you are trying to deploy the app with SQLite3 as database. I had to learn postgreSQL to deploy on Heroku.

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