使用gunicorn部署Django没有名为ImportError的模块:没有名为validation的模块

2024-03-21

我正在尝试使用 nginx、gunicorn 和 virtualenv 部署我的 Django 项目。但我在运行此评论时遇到以下错误

sudo gunicorn_django --bind test.com:8001

Log :

Traceback (most recent call last):
  File "/opt/postjust/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
    worker.init_process()
  File "/opt/postjust/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
    self.wsgi = self.app.wsgi()
  File "/opt/postjust/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/postjust/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 105, in load
    mod = util.import_module("gunicorn.app.django_wsgi")
  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/opt/postjust/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 21, in <module>
    from django.core.management.validation import get_validation_errors
ImportError: No module named validation
[2015-02-23 00:58:17 +0200] [10584] [INFO] Worker exiting (pid: 10584)
[2015-02-23 00:58:17 +0200] [10581] [INFO] Shutting down: Master
[2015-02-23 00:58:17 +0200] [10581] [INFO] Reason: Worker failed to boot.

该项目在本地运行良好。

这是我的设置.py file :

"""
Django settings for postjust project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'jb-@(98(ew4kkociwv+2y(3799r*vug7-$g)e=6wsxigrk30=!'

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

TEMPLATE_DEBUG = False

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'postjust.urls'

WSGI_APPLICATION = 'postjust.wsgi.application'


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

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

# Internationalization
# https://docs.djangoproject.com/en/1.7/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/1.7/howto/static-files/

STATIC_URL = '/static/'

我在 virtualenv 上的 pip 列表:

姜戈 (1.7.4)

枪兽 (19.2.1)

点 (6.0.8)

安装工具 (12.0.5)

--Python 2.7.8


改变gunicorn_django to gunicorn newApp.wsgi:application应该解决这个问题。

Using gunicorn_django不再推荐。这是因为它调用django_wsgi.py它已被弃用并引发导入错误。

更多信息:http://www.rkblog.rk.edu.pl/w/p/first-impressions-django-17-beta-upgrade-young-project/ http://www.rkblog.rk.edu.pl/w/p/first-impressions-django-17-beta-upgrade-young-project/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用gunicorn部署Django没有名为ImportError的模块:没有名为validation的模块 的相关文章

  • 用于多输入图像的 VGG16 网络

    我正在尝试将 VGG16 网络用于多个输入图像 使用具有 2 个输入的简单 CNN 训练该模型给了我一个 acc 大约 50 这就是为什么我想使用 VGG16 这样的既定模型进行尝试 这是我尝试过的 imports from keras a
  • 在 Django 中访问“媒体”文件

    我很喜欢 Django 但是开发环境中的静态和媒体文件业务让我抓狂 请把我从愚蠢中拯救出来 我在我的开发机器上 我有文件夹media在我的项目目录的根目录中 In settings py我有 MEDIA ROOT and MEDIA URL
  • Python 列联表

    作为我正在编写的项目的一部分 我正在生成很多很多列联表 工作流程是 获取具有连续 浮点 行的大型数据数组 并通过分箱将其转换为离散整数值 例如 结果行的值为 0 9 将两行切片为向量 X 和 Y 并生成列联表 https en wikipe
  • dask groupby 不合并分区

    我有一组数据 我想要对其进行一些简单的 groupby count 操作 但我似乎无法使用 dask 来完成此操作 我很可能不理解 dask 中执行 groupby reduce 的方式 特别是当索引位于分组键中时 所以我将用玩具数据来说明
  • PyCharm 虚拟环境和 Anaconda 环境有什么区别?

    当我在 PyCharm 中创建新项目时 它会创建一个新的虚拟环境 我读到 当我执行Python脚本时 它们是使用此环境中的解释器而不是系统环境来执行的 因此 如果我需要安装一些软件包 我只能将它们安装在这个环境中 而不是在系统环境中 这很酷
  • pandas dataframe 视图与复制,我如何区分?

    有什么区别 pandas df loc col a col b and df loc col a col b 下面的链接没有提到后者 尽管它有效 两者都拉视图吗 第一个拉取视图 第二个拉取副本吗 http pandas pydata org
  • 单词和表情符号计数器

    我有一个包含 clear message 列的数据框 并且创建了一个用于计算每行中所有单词的列 history word count history clear message apply lambda x Counter x split
  • 如何使用不同的类和导入动态地使用 Python 日志记录来更改文件句柄

    我无法执行即时日志文件句柄更改 例如 我有3节课 one py import logging class One def init self txt logging debug Hey I m the class One and I say
  • 没有名为“_pywrap_tensorflow_internal”的模块

    在尝试验证tensorflow gpu的安装时 在尝试执行 import tensorflow as tf 时出现ImportError 我在 Windows 7 上使用 Quadro K620 Tensorflow 是使用 pip 安装的
  • 后视模式无效

    为什么这个正则表达式在 Python 中有效 但在 Ruby 中无效
  • 跳过一个端点的 Flask 日志记录?

    我有一个 Python Flask 应用程序 有一项运行状况检查经常访问一个端点 但我不想在日志中看到它 如何仅禁用一个 GET 端点的日志记录 而保留其他所有端点的日志记录 艾蒂安 贝尔萨克为我指明了正确的方向 这就是我的实现方式 fro
  • 带有第二个 y 轴的 Seaborn 图

    i wanted to know how to make a plot with two y axis so that my plot that looks like this to something more like this by
  • 在 Python 的内置数字类型上,repr 和 str 总是相同吗?

    Are repr and strPython 内置数字类型相同 int bool float and complex 或者是否存在 深奥的 两者可能产生不同结果的情况 SO的相关问题 例如this one https stackoverfl
  • 如何获得 GTK 中的默认颜色?

    Context 在 GTK 3 中 人们可以设置自己的主题 甚至默认主题 Adwaita 也提供两种变体 浅色和深色 当我编写自己的小部件 用Python 时 我需要获取这些颜色以避免在黑色上绘制黑色或在白色上绘制白色 Question 如
  • 如何在 Jupyter 笔记本的 HTML 输出中获取垂直滚动条

    当使用具有 500 行的 Excel 在 Jupyter Notebooks 中运行以下代码时 import pandas as pd pd set option display min rows 50 pd set option disp
  • 在 Python 中规范化数字列表

    我需要对值列表进行标准化以适应概率分布 即在 0 0 和 1 0 之间 我明白how标准化 但很好奇 Python 是否有一个函数可以自动执行此操作 我想从 raw 0 07 0 14 0 07 to normed 0 25 0 50 0
  • 如何从初始化参数中正确设置 Python 类属性

    作为一名 Python 程序员 我经常声明类似的类 class Foo def init self attr1 attr2 attr3 attr4 attr5 attr6 attr7 attr8 attr9 self attr1 attr1
  • django:自动为现有用户创建用户配置文件

    我今天在我的项目中添加了一个新的 UserProfile 模型 class UserProfile models Model user models OneToOneField User def unicode self return u
  • 将数据帧转换为多列的系列

    我尝试将数据帧转换为系列但它显示以下错误 我使用 pandas Series Dataframe gt 将 Dataframe 转换为系列 我想要第一张图像格式的输出 请尝试以下方法从提到的数据中获取 Series 对象 假设data是您正
  • 将行追加到 Pandas DataFrame 添加 0 列

    我正在创建一个 Pandas DataFrame 来存储数据 不幸的是 我无法提前知道我将拥有的数据行数 所以我的方法如下 首先 我声明一个空的 DataFrame df DataFrame columns col1 col2 然后 我附加

随机推荐