首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >python中的<冻结importlib._bootstrap>错误

python中的<冻结importlib._bootstrap>错误
EN

Stack Overflow用户
提问于 2022-09-16 19:31:09
回答 1查看 488关注 0票数 -1

我的项目名称是宝洁,我已经把这个项目从我的电脑转移到笔记本电脑,因此我面临错误。

我几乎尽了一切努力来解决这个错误,但没有一个对我有用。

modules

  • Executed

  • 安装了所有缺少的
  1. manage.py (makemigrations/),commands
    1. Checked安装了我安装的应用程序。(什么都没有丢失)模型在数据库中被迁移。现在只有有错误。

我的python版本是3.10.7

错误:

代码语言:javascript
运行
复制
    Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application
   return import_string(app_path)
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\utils\module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\utils\module_loading.py", line 15, in cached_import
    module = import_module(module_path)
  File "D:\1.Coding Softwares\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\Dalvi\Desktop\Anish\Python Project\Online-Proctor-System\proctor\proctor\wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
    return WSGIHandler()
    handler = self.get_handler(*args, **options)
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 31, in get_handler        
    handler = super().get_handler(*args, **options)
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\core\management\commands\runserver.py", line 78, in get_handler
    return get_internal_wsgi_application()
  File "C:\Users\Dalvi\Envs\proctor\lib\site-packages\django\core\servers\basehttp.py", line 49, in get_internal_wsgi_application
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'proctor.wsgi.application' could not be loaded; Error importing module.

代码语言:javascript
运行
复制
├───adminsite (app)
│   ├───migrations
│   │   └───__pycache__
│   └───__pycache__
├───logreg (app)
│   ├───migrations
│   │   └───__pycache__
│   └───__pycache__
├───proctor (project)
│   └───__pycache__
├───static
│   ├───css
│   │   ├───adminsite
│   │   ├───login
│   │   └───usersite
│   ├───images
│   │   └───adminsite
│   └───js
│       ├───adminsite
│       └───usersite
├───static_root
│   ├───admin
│   │   ├───css
│   │   │   └───vendor
│   │   │       └───select2
│   │   ├───fonts
│   │   ├───img
│   │   │   └───gis
│   │   └───js
│   │       ├───admin
│   │       └───vendor
│   │           ├───jquery
│   │           ├───select2
│   │           │   └───i18n
│   │           └───xregexp
│   ├───css
│   │   ├───adminsite
│   │   ├───login
│   │   └───usersite
│   ├───images
│   │   └───adminsite
│   ├───js
│   │   ├───adminsite
│   │   └───usersite
│   └───static_root
│       ├───admin
│       │   ├───css
│       │   │   └───vendor
│       │   │       └───select2
│       │   ├───fonts
│       │   ├───img
│       │   │   └───gis
│       │   └───js
│       │       ├───admin
│       │       └───vendor
│       │           ├───jquery
│       │           ├───select2
│       │           │   └───i18n
│       │           └───xregexp
│       ├───css
│       │   ├───adminsite
│       │   ├───login
│       │   └───usersite
│       ├───images
│       │   └───adminsite
│       └───js
│           ├───adminsite
│           └───usersite
├───templates
│   ├───adminsite
│   ├───logreg
│   └───usersite
└───usersite (app)
    ├───migrations
    │   └───__pycache__
    └───__pycache__

settings.py of project (proctor)

代码语言:javascript
运行
复制
import os
from pathlib import Path

import proctor

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-!2eg$jgi04pesan7_)@^((#o)fq($9namjy&gii=mi0s@ko-+n'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    # logreg app
    'logreg.apps.LogregConfig',

    # crispy forms
    'crispy_forms',
   'adminsite.apps.AdminsiteConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'phonenumber_field',
    'usersite',
    
]

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',
    'django_auto_logout.middleware.auto_logout',
    
]

ROOT_URLCONF = 'proctor.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates/usersite'),os.path.join(BASE_DIR, 'templates/logreg'),os.path.join(BASE_DIR, 'templates/adminsite')],
        '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 = 'proctor.wsgi.application'

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME':'proctor',
        'USER':'root',
        'PASSWORD':'root',
        'HOST':'127.0.0.1', 
        'PORT':'3306',
    }
}


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/4.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
   os.path.join(BASE_DIR, "static"),
   
]

STATIC_ROOT =os.path.join(BASE_DIR, "static_root")
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

# Base url to serve media files
MEDIA_URL = '/media/'

# Path where media is stored
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')



DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

CRISPY_TEMPLATE_PACK = 'bootstrap4'

#AUTO_LOGOUT = {'IDLE_TIME': 200}

SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'

wsgi.py of project (proctor)

代码语言:javascript
运行
复制
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proctor.settings')

application = get_wsgi_application()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-17 09:24:31

安装了Python的较低版本,即从3.10到3.7,然后安装了所有缺少的模块

代码语言:javascript
运行
复制
pip install pymysql
python -m pip install Pillow
pip install cryptography
pip install django_auto_logout
pip install requests_html
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73749550

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档