django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb的解决方法

今天自学django创建mysql数据库表的时候报了如下错误:

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
在我百度查询下,终于找到了问题所在,就是没有安装MySQL-python。基于这个问题,网上提供了各种解决方案,大部分都是基于Python 包的

安装和管理工具pip命令去安装MySQL-python(在cmd命令行下执行pip install MySQL-python安装),然而在安装的过程中确报了如下错误:

Command "d:\python27\python.exe -u -c "import setuptools, tokenize;__file__=‘c:\\users\\tangbo\\appdata\\local\\temp\\pip-build-wif0di\\mysql-python\\setup.py‘;exec(compile(getattr(tokenize, ‘open‘, open)(__file__).read().replace(‘\r\n‘, ‘\n‘), __file__, ‘exec‘))" install --record c:\users\tangbo\appdata\local\temp\pip-yvc9jx-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\tangbo\appdata\local\temp\pip-build-wif0di\mysql-python\

我找到了一种更加简单的方式来解决这个问题:

1、下载MySQL-python的安装包,地址如下:

https://pypi.python.org/pypi/MySQL-python/1.2.5

打开网页,定位到如下图所示的位置,下载箭头所指的安装包(我的机器是64位的,下载这个32位的也没有问题):

2、点击安装包安装

点击后设置路径,示意图如下:

其中Python Directory:设置为python安装的路径

  Installation Directory:设置为python安装路径下的\lib\site-pack-ages\目录下

完成上述步骤,MySQL-python安装完毕。

django创建mysql数据库表的程序顺利运行。eclipse下正确运行的结果如下图所示:

 

时间: 2024-12-23 09:24:24

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb的解决方法的相关文章

django报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

django 迁移数据库报错 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclient? 解决方案:在settings.py同级目录中的__init__.py文件中加入: import pymysql pymysql.install_as_MySQLdb() 原文地址:https://www.cnblogs.com/pfeiliu/p/12045021

django配置使用mysql数据库运行报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

今天在把django的默认数据库sqlite3切换为MySQL数据库时报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb' 报错原因:django虚拟环境没有安装pymysql模块 解决: 先安装pymysql:pip install pymysql 然后在项目的 init.py 文件中添加以下代码: 把django的默认数据库sqlite3切

Django启动时找不到mysqlclient处理 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

在使用Django2.0 并配置了mysql作为数据库时,启动报错: 报错1:找不到mysqlclient django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? 解决方法 项目(settings.py同级)目录中__init__.py中添加 import pymysql pymysql.install_as_MySQLdb() 报错2:版本检查

后台创建管理员 createsuperuser 时 报django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

结果版本0.9.3 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 需要pip指定版本号安装 结果清华源没有这个版本,换阿里云 pip install -i https://mirrors.aliyun.com/pypi/simple/ pymysql==1.3.13 阿里也没有,只能国外了 pip install jupyter -i ht

django.core.exceptions.ImproperlyConfigured:

错误提示: django.core.exceptions.ImproperlyConfigured: WSGI application 'luffy_permission.wsgi.application' could not be loaded; Error importing module: 'No module named 'rbac.middlewares.rbac'' 如何修改呢??? 1.问题的由来? pycharm在代码练习的过程会提供很多方便的服务,比如说中途要给莫一个.py文件

python交互式环境,django模板报错:django.core.exceptions.ImproperlyConfigured

环境: ubuntu django 1.5 virtualenv环境中 (web01)[email protected]:~/.virtualenvs/web01/dj_01/pro01$ python Python 2.7.6 (default, Mar 22 2014, 22:59:56)  [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license&q

django交互模式使用模板报:django.core.exceptions.ImproperlyConfigured

(dj_01)[email protected]:~/.virtualenvs/dj_01/mysite$ pwd /home/milo/.virtualenvs/dj_01/mysite (dj_01)[email protected]:~/.virtualenvs/dj_01/mysite$ python >>> from django import template >>> t = template.Template('My name is {{ name }}.

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.9.3.None

报错环境: python=3.7,django=2.2,PyMySQL=0.9.3 抛出异常: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 报错场景: 1.启动django项目 2.更新表:python manage.py makemigrations 报错原因:安装Django后不想折腾mysqlclient那堆库文件,直接装了pymy

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configur

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. import xadmin时出了这个问