0

我正在尝试将我的 Django 应用程序部署到 DigitalOcean VPS 上。python manage.py collectstatic当我遇到此错误时,我设置了所有内容并即将运行:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/demo/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/home/demo/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 337, in execute
    django.setup()
  File "/home/demo/.local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/demo/.local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/demo/.local/lib/python2.7/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named embed_video

问题是我embed_video已经使用pip install django-embed-video. 我的问题是没有检测到该应用程序。

如果有帮助,我将 PostgreSQL 实现为生产数据库,将 SQLite 实现为开发数据库,​​并且我还将使用 nginx 和 gunicorn 作为该过程的一部分。

既然人们问,这是我的settings.py

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



DEBUG = False

ALLOWED_HOSTS = []
PROJECT_DIR_PATH = path.dirname(path.normpath(path.abspath(__file__)))


# Application definition

INSTALLED_APPS = [
        'about.apps.AboutConfig',
        'forms.apps.FormsConfig',
        'resources.apps.ResourcesConfig',
        'contact.apps.ContactConfig',
        'blog.apps.BlogConfig',
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'embed_video',
        'bootstrap3',
]

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

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [(os.path.join(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',
                                'django.template.context_processors.media',
                                'django.template.context_processors.static',
            ],
        },
    },
]

WSGI_APPLICATION = 'nydkcd11.wsgi.application'





#PRODUCTION DATABASE
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'databse',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'myuser',
        'PASSWORD': 'password',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}


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',
    },
]




LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True



MEDIA_ROOT = 'media/'
MEDIA_URL = '/media/'




#PRODUCTION
STATIC_ROOT = '/opt/myenv/static/'

STATIC_URL = '/static/'
4

1 回答 1

1

您需要检查模块是否正确安装在 Python 中,您可以先尝试 tp check withpip list以查看安装在 Python 中的模块列表。

然后尝试手动导入模块,把它放在控制台中:

python import embed_video

并检查embed_video后点击return时是否有错误。

你在你的电脑上安装了更多的 Python ???,你在使用虚拟环境吗???,所有这些都可能是你错误的根源。

于 2017-06-23T19:48:54.667 回答