django - 我正在尝试使用 Heroku CLI 在 Heroku 中部署我的 django 项目我遇到安装错误

标签 django ubuntu visual-studio-code heroku heroku-cli

一切正常,直到我运行这个命令:

git push heroku master
我得到这个按摩:
git push heroku master
Enumerating objects: 55, done.
Counting objects: 100% (55/55), done.
Delta compression using up to 8 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (55/55), 15.40 KiB | 685.00 KiB/s, done.
Total 55 (delta 14), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Python,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the buildpack default: python-3.10. 
remote:        To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.10.4
remote: -----> Installing pip 22.0.4, setuptools 60.10.0 and wheel 0.37.1
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting argcomplete==1.8.1
remote:          Downloading argcomplete-1.8.1-py2.py3-none-any.whl (34 kB)
remote:        Collecting argh==0.26.2
remote:          Downloading argh-0.26.2-py2.py3-none-any.whl (30 kB)
remote:        Collecting attrs==19.3.0
remote:          Downloading attrs-19.3.0-py2.py3-none-any.whl (39 kB)
remote:        Collecting Automat==0.8.0
remote:          Downloading Automat-0.8.0-py2.py3-none-any.whl (31 kB)
remote:        Collecting blessings==1.6
remote:          Downloading blessings-1.6.tar.gz (19 kB)
remote:          Preparing metadata (setup.py): started
remote:          Preparing metadata (setup.py): finished with status 'error'
remote:          error: subprocess-exited-with-error
remote:
remote:          × python setup.py egg_info did not run successfully.
remote:          │ exit code: 1
remote:          ╰─> [1 lines of output]
remote:              error in blessings setup command: use_2to3 is invalid.
remote:              [end of output]
remote:
remote:          note: This error originates from a subprocess, and is likely not a problem with pip.
remote:        error: metadata-generation-failed
remote:
remote:        × Encountered error while generating package metadata.
remote:        ╰─> See above for output.
remote:
remote:        note: This is an issue with the package mentioned above, not pip.
remote:        hint: See above for details.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to murmuring-badlands-28149.
remote:
To https://git.heroku.com/murmuring-badlands-28149.git
 ! [remote rejected] master -> master (pre-receive hook declined)
设置.py 文件:
import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
# BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_DIR = os.path.join(BASE_DIR, 'static')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pk5^b0zrhl+*h*8$=$fs(kq1nw(2)&j^$$e2gjk#64=5yrun4x'

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

ALLOWED_HOSTS = ['weather-mahmood1.herokuapp.com', '127.0.0.1']



# Application definition

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

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 = 'weather_pro.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATES_DIR],
        '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 = 'weather_pro.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR,'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.1/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.1/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.1/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [STATIC_DIR]
我使用 Windows 10,并从 Ubuntu 子系统 20.04 运行此代码

最佳答案

您可能需要将您的祝福库升级到 1.7。
https://github.com/erikrose/blessings
从他们的发行说明中:

1.7:
Drop support for Python 2.6 and 3.3, which are end-of-lifed.
Switch from 2to3 to the six library.

关于django - 我正在尝试使用 Heroku CLI 在 Heroku 中部署我的 django 项目我遇到安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72214372/

相关文章:

linux - 如何终止/停止不断刷新其 PID 的进程?

python - Django 中 DateTimeField 过滤器的问题

php - 可以使用终端访问 mysql 数据库,但使用 php 时收到 "access denied"消息

python - 我在虚拟环境外安装了一个包,但不能在虚拟环境中使用它

linux - 如何使用 Bash/Shell 编程更改文本行?

angular - 错误 Angular 13 : ngForOf not used by any directive. ..无法绑定(bind)到 'ngForOf'

visual-studio-code - 是什么 !在 vscode 中我的文件名旁边签名

visual-studio-code - VS Code 的扩展以启动 EXE 并插入从 EXE 返回的文本

django - 使用 Nginx 避免 Django 因不允许的主机而出现 500 错误

python 导入 MySQLdb