Django 使用mysql 所遇到问题一:Error loading MySQLdb module
在配置完mysql 的配置信息后执行 python manage.py runserver 时出现如下错误。(py3的环境)
解决
在 python2 中,使用 pip install mysql-python
进行安装连接MySQL的库,使用时 import MySQLdb
进行使用
在 python3 中,改变了连接库,改为了 pymysql 库,使用pip install pymysql
进行安装,直接导入import pymysql
使用
本来在上面的基础上把 python3 的 pymysql 库安装上去就行了,但是问题依旧
经过查阅得知, Django 依旧是使用 py2 的 MySQLdb 库的,得到进行适当的转换才行
在__init__.py
文件中添加以下代码
import pymysql
pymysql.install_as_MySQLdb()
Django 使用mysql 所遇到问题一:Error loading MySQLdb module的更多相关文章
- Error loading MySQLdb module: No module named 'MySQLdb'----------- django成功连接mysql数据库的方法
在进行django学习过程中,尝试使用框架连接mysql数据库,启动服务器的时候经常遇到Error loading MySQLdb module: No module named 'MySQLdb' ...
- django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python?
Error msg: Unhandled exception in thread started by <function check_errors.<locals>.wrapper ...
- 【Django】django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
最近学习Django的过程中,在cmd打算使用python manage.py shell来测试数据的时候,当我一导入自己写的model类,就发现报了这个错误django.core.exception ...
- 【Django】django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
今天创建APP的时候报这个错误django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you in ...
- django无法同步数据库 Error loading MySQLdb module: No module named ‘MySQLdb‘
最近在学习Python,打算先看两个在线教程,再在github上找几个开源的项目练习一下,在学到“被解放的姜戈”时遇到django同步数据库时无法执行的错误,记录一下. 错误现象: 执行python ...
- django报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
django 迁移数据库报错 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you ins ...
- Hue - Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or
解决下面两点异常 >> 1. Hue页面 点击DB 查询时弹出: Error loading MySQLdb module: libmysqlclient.so.20: cannot op ...
- 发生服务器错误: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory
在hue上配置Mysql的时候,出现的错误: 发生服务器错误: Error loading MySQLdb module: libmysqlclient.so.18: cannot open sha ...
- Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory
在hue上配置Mysql的时候,出现的错误: 发生服务器错误: Error loading MySQLdb module: libmysqlclient.so.18: cannot open sha ...
随机推荐
- SpringBoot(十一)_springboot热部署
在开发中,后台修改了代码就要重新启动服务,很是费劲,现在我们可以让SpringBoot自动编译 热启动就需要用到我们在一开始引入的另外一个组件:devtools.它是 Spring Boot 提供的一 ...
- NOIP赛前集训营-提高组(第一场)#A 中位数
题目描述 小N得到了一个非常神奇的序列A.这个序列长度为N,下标从1开始.A的一个子区间对应一个序列,可以由数对[l,r]表示,代表A[l], A[l + 1], ..., A[r]这段数.对于一 ...
- win7右下角的同步中心怎么去除
“开始”-“运行”-“regedit”,在“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Syncmgr\Handlers” ...
- HTTP返回代码 201 304 404 500等代表的含义
在网站日志中,我们经常会看到很多返回的http代码,如201.304.404.500等等.可是这些具体的返回的HTTP代码究竟什么含义呢,在此做一下知识普及吧,记不住不要紧,到时候看看就行了,但最主要 ...
- 安装mysql-5.6版本步骤与卸载
官网下载完解压后: 1.环境变量配置Path D:\mysql-5.6.40-winx64\bin(你的mySql5.6的路径到bin)2.找到D:\mysql-5.6.40-winx64文件中的 ...
- HDU 6231
K-th Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- 《编程快速上手》--web抓取--利用webbrowser模块的mapIT.py
1.代码如下 #! python3 # mapIT.py - Launches a map in the browser using an address from the # command lin ...
- python中的关键字符
from keyword import kwlistprint(kwlist)for i in kwlist: print(i) 可以显示所有的关键字符,开发者不要重新赋予其他值. a = 10000 ...
- 转:UINavigationBar返回上一级出现nested pop animation can result in corrupted navigation bar
[self.navigationController popViewControllerAnimated:NO]; 出现上面的错误是因为pop的时候要确保先让本页面加载完成,即如果在viewDidLo ...
- Git和Github入门
推文:官方手册,十分详细 推文:git和github快速入门 一.git使用 1.git安装 (1)windows 网站:https://git-scm.com/download/win下载安装即可 ...