首页 > 数据库 >django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.mysql' isn�

django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.mysql' isn�

时间:2024-08-31 08:53:48浏览次数:12  
标签:available core lib py django File line backend

 

没解决此问题

(venv) [root@VM-8-12-centos MYPROJECT-django20240830]# python3 manage.py  runserver 0.0.0.0:8080
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/backends/mysql/base.py", line 5, in <module>
    from .features import DatabaseFeatures
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/backends/mysql/features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
    from django.contrib.gis.db import models
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
    from django.contrib.gis.gdal import GDALException
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/gis/gdal/datasource.py", line 36, in <module>
    from ctypes import byref
  File "/usr/local/python3/lib/python3.8/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/python3/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/models/base.py", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/models/base.py", line 326, in add_to_class
    value.contribute_to_class(cls, name)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/models/options.py", line 207, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/utils/connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/utils.py", line 204, in create_connection
    backend = load_backend(db['ENGINE'])
  File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/django/db/utils.py", line 122, in load_backend
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.mysql' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

=======================================================


=================================

[root@VM-8-12-centos django20240830]# pip list
Package             Version
------------------- ----------
asgiref             3.8.1
bleach              3.1.5
certifi             2020.4.5.2
cffi                1.17.0
chardet             3.0.4
colorama            0.4.3
cryptography        43.0.0
Django              3.2.18
django-cors-headers 4.3.1
django-guardian     2.4.0
django-model-utils  4.2.0
django-redis        5.1.0
djangorestframework 3.14.0
docutils            0.16
download            0.3.5
GDAL                3.4.1
idna                2.9
jeepney             0.8.0
keyring             21.2.1
numpy               1.24.4
packaging           20.4
Pillow              8.4.0
pip                 24.2
pkginfo             1.5.0.1
pycparser           2.22
Pygments            2.6.1
PyMySQL             1.1.1
pyparsing           2.4.7
pytz                2022.7.1
pywin32-ctypes      0.2.0
readme-renderer     26.0
redis               3.5.3
requests            2.24.0
requests-toolbelt   0.9.1
rfc3986             1.4.0
SecretStorage       3.3.3
setuptools          70.1.0
six                 1.15.0
sqlparse            0.4.3
tqdm                4.47.0
twine               3.2.0
typing_extensions   4.1.1
urllib3             1.25.9
uWSGI               2.0.26
webencodings        0.5.1
wheel               0.43.0
xlrd                1.2.0
xlwt                1.3.0
(venv) [root@VM-8-12-centos django20240830]#
=================================

# yum install mysql-gis
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel                                                                                                                                                                  | 4.3 kB  00:00:00     
extras                                                                                                                                                                | 2.9 kB  00:00:00     
os                                                                                                                                                                    | 3.6 kB  00:00:00     
updates                                                                                                                                                               | 2.9 kB  00:00:00     
No package mysql-gis available.
Error: Nothing to do

=================================

然后,您可以登录到MySQL,并检查GIS扩展是否已经安装:

mysql -u root -p

登录后,运行以下SQL命令:

SHOW PLUGINS;

查找geometry插件,如果其状态为ACTIVE,则表示GIS扩展已成功安装并启用。

 

 

=================================

MySQL支持以下数据类型:
Geometry:可以存储所有的几何类型
Point:简单点
LINESTRING:简单线
POLYGON:简单面
MULITIPOINT:多点
MULITILINESTRING:多线
MUILITIPOLYGON:多面
GEOMETRYCOLLECTION:任何几何集合

 

标签:available,core,lib,py,django,File,line,backend
From: https://www.cnblogs.com/emanlee/p/18389425

相关文章

  • Vue3+.NET7最新框架实战,手写电商管理后台|2023全新录制,前后分离架构(C#/.NET6/.NET Co
    Vue3+.NET7最新框架实战,手写电商管理后台|2023全新录制,前后分离架构(C#/.NET6/.NETCore)https://pan.baidu.com/s/1SBt4RTT_m6uA9pk857KlcQ?pwd=6666https://www.bilibili.com/video/BV16s4y1m7bd/?spm_id_from=333.337.search-card.all.click&vd_source=e6b56a12a1d9ef11f6c13......
  • django中的数据库连接池实现
    1、第一步安装数据库连接池第三方模块pipinstalldjango-db-connection-pool2、在项目目录下的settings文件中添加下面配置DATABASES={"default":{'ENGINE':'dj_db_conn_pool.backends.mysql','NAME':'day04',#数据库名字......
  • ASP.NET Core6.0-wwwroot文件夹无法访问解决方法
    默认情况下,ASP.NETCore项目中的wwwroot文件夹被视为Web根文件夹。静态文件可以存储在Web根目录下的任何文件夹中,并可以使用该根目录的相对路径进行访问。在ASP.NET应用程序中,可以从应用程序的根文件夹或其下的任何其他文件夹提供静态文件。这已在ASP.NETCore中更改。现在,只有Web......
  • CoreNext主题1.5.2免授权 | WordPress主题模板
    CoreNext主题1.5.2免授权 | WordPress主题模板探索无限可能:CoreNext主题1.5.2免授权WordPress主题模板在这个数字化的时代,网站已成为个人品牌和企业展示的窗口。对于那些追求独特风格和高效管理的用户来说,选择一个合适的WordPress主题模板至关重要。今天,我们将深入探讨Core......
  • 计算机毕业设计django+vue大学校园生活交流平台【开题+论文+程序】
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容研究背景随着信息技术的飞速发展和互联网的普及,大学生活日益丰富多彩,但同时也面临着信息交流与资源共享的难题。传统的线下公告板、口口相传等方式......
  • AGC041D Problem Scores 题解
    在分值不降的条件下,要使任意一个大小为\(k\)的子集\(S\)内题目的分值之和少于任意一个大小为\(k+1\)的子集\(T\)内题目的分值之和,容易发现只需要取\(S\)为后\(k\)道题目,\(T\)为前\(k+1\)道题目时满足限制即可。换而言之,只需要对满足\(a\)的每一段长为\(k+......
  • .net Core发布IIS的各种异常解答
    一.IIS启动之后发布项目失败原因以及解决方案1.查看本机应用池模块是否有AspNetCoreMoudleV2,如果没有,需要去微软官网下载一个HostingBundle安装2.查看程序池的.netCLR版本要选择无托管代码3.标识应该选择localsystem二.打开网页提示用户登录数据失败原因以及解决方案1.......
  • 计算机毕业设计django+vue个人博客系统【开题+论文+程序】
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容研究背景随着互联网技术的飞速发展,个人博客作为展示个人思想、分享知识与经验的重要平台,其重要性日益凸显。传统的博客系统多依赖于单一的技术栈,如......
  • Serilog文档翻译系列(二) - 设置AspNetCore应用程序
     Serilog日志记录适用于ASP.NETCore。此包将ASP.NETCore的日志消息通过Serilog进行路由,使你可以将有关ASP.NET内部操作的信息写入与应用程序事件相同的Serilog接收器中。安装并配置了Serilog.AspNetCore后,你可以直接通过Serilog或ASP.NET注入的任何ILogger......
  • net core自定义 Configuration Provider
    创建CustomConfigurationProvider首先,我们需要创建一个自定义的ConfigurationSource和ConfigurationProvider来支持配置文件的读取和监控。publicclassCustomConfigurationSource:IConfigurationSource{publicstringFilePath{get;}publicCustomConfig......