Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django应用程序与Gunicorn一起失败,与Runserver一起正常_Python_Django_Heroku - Fatal编程技术网

Python Django应用程序与Gunicorn一起失败,与Runserver一起正常

Python Django应用程序与Gunicorn一起失败,与Runserver一起正常,python,django,heroku,Python,Django,Heroku,为gunicorn开始脚本编辑 我试图调试一个在本地工作的应用程序,但在部署到Heroku时遇到了问题。使用heroku local或gunicorn threepoints.wsgi:application,我可以看到这个堆栈跟踪 10:43:00 AM web.1 | Traceback (most recent call last): 10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/

为gunicorn开始脚本编辑

我试图调试一个在本地工作的应用程序,但在部署到Heroku时遇到了问题。使用heroku local或gunicorn threepoints.wsgi:application,我可以看到这个堆栈跟踪

10:43:00 AM web.1 |  Traceback (most recent call last):
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
10:43:00 AM web.1 |      worker.init_process()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
10:43:00 AM web.1 |      self.wsgi = self.app.wsgi()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
10:43:00 AM web.1 |      self.callable = self.load()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
10:43:00 AM web.1 |      return self.load_wsgiapp()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
10:43:00 AM web.1 |      return util.import_app(self.app_uri)
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
10:43:00 AM web.1 |      __import__(module)
10:43:00 AM web.1 |    File "/Users/cbuddeke/Dropbox/DC-Development/ThreePoints Website/tp/threepoints/wsgi.py", line 19, in <module>
10:43:00 AM web.1 |      application = get_wsgi_application()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
10:43:00 AM web.1 |      django.setup()
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
10:43:00 AM web.1 |      apps.populate(settings.INSTALLED_APPS)
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
10:43:00 AM web.1 |      app_config = AppConfig.create(entry)
10:43:00 AM web.1 |    File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
10:43:00 AM web.1 |      mod = import_module(mod_path)
10:43:00 AM web.1 |    File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
10:43:00 AM web.1 |      __import__(name)
10:43:00 AM web.1 |  ImportError: No module named wagtail
10:43:00 AM web.1 |  [2016-10-28 14:43:00 +0000] [24197] [INFO] Worker exiting (pid: 24197)
10:43:00 AM web.1 |  [2016-10-28 10:43:00 -0400] [24194] [INFO] Shutting down: Master
10:43:00 AM web.1 |  [2016-10-28 10:43:00 -0400] [24194] [INFO] Reason: Worker failed to boot.
冰点

beautifulsoup4==4.5.1
Django==1.10.1
django-bootstrap3==7.1.0
django-extensions==1.7.4
django-modelcluster==2.0
django-taggit==0.18.3
django-treebeard==4.0.1
djangorestframework==3.4.7
docopt==0.4.0
html5lib==0.999999
mailchimp==2.0.9
Pillow==3.3.1
pytz==2016.6.1
requests==2.11.1
six==1.10.0
Unidecode==0.4.19
wagtail==1.6.2
Werkzeug==0.11.11
whitenoise==3.2.2
Willow==0.3.1
我的设置是

from __future__ import absolute_import, unicode_literals

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

SECRET_KEY = 'xxxxxxxxxxxxxxxxxx'
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
MAILCHIMP_API_KEY = os.environ["MAILCHIMP_API_KEY"]

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

ALLOWED_HOSTS = [
    'threepoints.io',
    'localhost',
    'three-points.herokuapp.com'
]

# Application definition

INSTALLED_APPS = [
    'blog',
    'home',
    'search',

    'wagtail.wagtailforms',
    'wagtail.wagtailredirects',
    'wagtail.wagtailembeds',
    'wagtail.wagtailsites',
    'wagtail.wagtailusers',
    'wagtail.wagtailsnippets',
    'wagtail.wagtaildocs',
    'wagtail.wagtailimages',
    'wagtail.wagtailsearch',
    'wagtail.wagtailadmin',
    'wagtail.wagtailcore',

    'bootstrap3',
    'django_extensions',
    'mailchimp',
    'modelcluster',
    'taggit',

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    # 'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    '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',
    'django.middleware.security.SecurityMiddleware',

    'wagtail.wagtailcore.middleware.SiteMiddleware',
    'wagtail.wagtailredirects.middleware.RedirectMiddleware',
    # 'whitenoise.middleware.WhiteNoiseMiddleware',
]

ROOT_URLCONF = 'threepoints.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(PROJECT_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 = 'threepoints.wsgi.application'


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

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

STATICFILES_DIRS = [
    os.path.join(PROJECT_DIR, 'static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'


# Wagtail settings

WAGTAIL_SITE_NAME = "threepoints"

# Base URL to use when referring to full URLs within the Wagtail admin backend -
# e.g. in notification emails. Don't include '/admin' or a trailing slash
BASE_URL = 'http://threepoints.io'

我不确定这里出了什么问题

您的gunicorn回溯告诉您问题:

ImportError:没有名为wagtail的模块

因此,您需要确保wagtail是重要的。通常这意味着
pip安装wagtail
,并在您的virtualenv中使用python运行gunicorn:


gunicorn--pythonpath=/path/to/virtualenv/bin/python threepoints.wsgi

您的gunicorn回溯告诉您问题:

ImportError:没有名为wagtail的模块

因此,您需要确保wagtail是重要的。通常这意味着
pip安装wagtail
,并在您的virtualenv中使用python运行gunicorn:


gunicorn--pythonpath=/path/to/virtualenv/bin/python threepoints.wsgi

请从Procfile
web:gunicorn threepoints.wsgi--log file-
中提供您的gunicorn启动脚本,这在终端中通过
gunicorn threepoints.wsgi:application
gunicorn threepoints.wsgi
进行确认虚拟人?如果是,,virtualenv是否包含所有必要的软件包,gunicorn是否配置为使用virtualenv?在我看来,您没有在项目的虚拟环境中运行gunicorn。请从Procfile
web:gunicorn threepoints.wsgi--log file-
中提供gunicorn启动脚本,这在终端中得到确认使用
gunicorn threepoints.wsgi:application
gunicorn threepoints.wsgi
是否在virtualenv中运行?如果是,virtualenv是否包含所有必要的包,gunicorn是否配置为使用virtualenv?在我看来,您并没有在项目的虚拟环境中运行gunicorn
from __future__ import absolute_import, unicode_literals

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

SECRET_KEY = 'xxxxxxxxxxxxxxxxxx'
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
MAILCHIMP_API_KEY = os.environ["MAILCHIMP_API_KEY"]

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

ALLOWED_HOSTS = [
    'threepoints.io',
    'localhost',
    'three-points.herokuapp.com'
]

# Application definition

INSTALLED_APPS = [
    'blog',
    'home',
    'search',

    'wagtail.wagtailforms',
    'wagtail.wagtailredirects',
    'wagtail.wagtailembeds',
    'wagtail.wagtailsites',
    'wagtail.wagtailusers',
    'wagtail.wagtailsnippets',
    'wagtail.wagtaildocs',
    'wagtail.wagtailimages',
    'wagtail.wagtailsearch',
    'wagtail.wagtailadmin',
    'wagtail.wagtailcore',

    'bootstrap3',
    'django_extensions',
    'mailchimp',
    'modelcluster',
    'taggit',

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    # 'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    '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',
    'django.middleware.security.SecurityMiddleware',

    'wagtail.wagtailcore.middleware.SiteMiddleware',
    'wagtail.wagtailredirects.middleware.RedirectMiddleware',
    # 'whitenoise.middleware.WhiteNoiseMiddleware',
]

ROOT_URLCONF = 'threepoints.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(PROJECT_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 = 'threepoints.wsgi.application'


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

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

STATICFILES_DIRS = [
    os.path.join(PROJECT_DIR, 'static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'


# Wagtail settings

WAGTAIL_SITE_NAME = "threepoints"

# Base URL to use when referring to full URLs within the Wagtail admin backend -
# e.g. in notification emails. Don't include '/admin' or a trailing slash
BASE_URL = 'http://threepoints.io'