加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-20 12:31:50 所属栏目:Python 来源:网络整理
导读:我试图使用nginx,gunicorn和virtualenv来部署我的Django项目.但是在运行此评论时我遇到了以下错误 sudo gunicorn_django --bind test.com:8001 记录: Traceback (most recent call last): File "/opt/postjust/lib/python2.7/site-packages/gunicorn/arbite
我试图使用nginx,gunicorn和virtualenv来部署我的Django项目.但是在运行此评论时我遇到了以下错误

sudo gunicorn_django --bind test.com:8001

记录:

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.

该项目在当地运行良好.

这是我的settings.py文件:

"""
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的点子列表:

Django(1.7.4)

gunicorn(19.2.1)

点子(6.0.8)

setuptools(12.0.5)

–Python 2.7.8

解决方法

将gunicorn_django更改为gunicorn newApp.wsgi:应用程序应修复此问题.

不再推荐使用gunicorn_django.这是因为它调用了不推荐使用的django_wsgi.py并抛出了导入错误.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读