ModuleNotFoundError:尝试> Python manage.py makemigrations | python 3.7,django 2.1.7时,没有名为“ DEGNet”的模块

时间:2019-02-27 03:58:22

标签: python django pythonanywhere

我在任何地方都使用python制作了一个Web应用程序,同时尝试为新的Profile模型进行迁移时,出现了错误:

> (pyshoptest-virtualenv) 20:23 ~/pyshop-test/pyshop (master)$ python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 224, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 12, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/migrations/autodetector.py", line 11, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/migrations/questioner.py", line 9, in <module>
    from .loader import MigrationLoader
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/migrations/loader.py", line 8, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder:
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder
    class Migration(models.Model):
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/db/models/base.py", line 87, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/apps/registry.py", line 249, in get_containing_app_config
    self.check_apps_ready()
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/apps/registry.py", line 131, in check_apps_ready
    settings.INSTALLED_APPS
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/conf/__init__.py", line 57, in __getattr__
    self._setup(name)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/site-packages/django/conf/__init__.py", line 107, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/bwc9876/.virtualenvs/pyshoptest-virtualenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'DEGNet'

我试图四处查看Settings.py和其他类似文件,但没有发现任何可能导致此错误的信息。

也在列出

  

Python manage.py帮助

在显示的帮助消息下方,我遇到了一个错误,

  

请注意,仅列出了Django核心命令,因为未正确配置设置(错误:没有名为“ DEGNet”的模块)。

我的设置文件如下:

  ALLOWED_HOSTS = ['*myusername*.pythonanywhere.com']


# Application definition

INSTALLED_APPS = [
    'users.apps.UsersConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'products.apps.ProductsConfig',
    'crispy_forms'


]

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

WSGI_APPLICATION = '*myusername*_pythonanywhere_com_wsgi.py'


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

STATIC_URL = '/home/*myusername*/*projectname*/static'

CRISPY_TEMPLATE_PACK = "bootstrap4"

LOGIN_REDIRECT_URL = "/products"

LOGIN_URL = 'login'

我的WebApp可以在当前模块上正常运行,但是我无法使makemigrations正常工作

1 个答案:

答案 0 :(得分:1)

在您的manage.py文件中,在pythonanywhere上更改DEGNet,它将起作用!祝你好运。