安装python时MySQLdb报错的问题描述及解决方法


Posted in Python onMarch 20, 2018

问题描述:

windows安装python mysqldb时报错python version 2.7 required,which was not found in the registry

网上很多方案,比如方案一:

Python3.x时, from _winreg import *  改为 from winreg import * 去掉下划线

import sys  
 from _winreg import *  
# tweak as necessary  
version = sys.version[:3]  
installpath = sys.prefix  
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)  
installkey = "InstallPath"  
pythonkey = "PythonPath"  
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (  
  installpath, installpath, installpath  
)  
def RegisterPy():  
  try:  
    reg = OpenKey(HKEY_CURRENT_USER, regpath)  
  except EnvironmentError as e:  
    try:  
      reg = CreateKey(HKEY_CURRENT_USER, regpath)  
      SetValue(reg, installkey, REG_SZ, installpath)  
      SetValue(reg, pythonkey, REG_SZ, pythonpath)  
      CloseKey(reg)  
    except:  
      print "*** Unable to register!"  
      return  
    print "--- Python", version, "is now registered!"  
    return  
  if (QueryValue(reg, installkey) == installpath and  
    QueryValue(reg, pythonkey) == pythonpath):  
    CloseKey(reg)  
    print "=== Python", version, "is already registered!"  
    return  
  CloseKey(reg)  
  print "*** Unable to register!"  
  print "*** You probably have another Python installation!"  
if __name__ == "__main__":  
  RegisterPy()

方案二:

这种也是我遇到的情况,是因为你的MySQLdb与python的版本不匹配,你要下载匹配的版本即可

总结

以上所述是小编给大家介绍的安装python时MySQLdb报错的问题描述及解决方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!

Python 相关文章推荐
多版本Python共存的配置方法
May 22 Python
Python 逐行分割大txt文件的方法
Oct 10 Python
Python生成8位随机字符串的方法分析
Dec 05 Python
django反向解析和正向解析的方式
Jun 05 Python
使用python Fabric动态修改远程机器hosts的方法
Oct 26 Python
numpy.linspace函数具体使用详解
May 27 Python
PyQt5显示GIF图片的方法
Jun 17 Python
Python数据结构与算法(几种排序)小结
Jun 22 Python
与Django结合利用模型对上传图片预测的实例详解
Aug 07 Python
Python递归函数 二分查找算法实现解析
Aug 12 Python
python 操作excel表格的方法
Dec 05 Python
Django项目如何获得SSL证书与配置HTTPS
Apr 30 Python
python如何定义带参数的装饰器
Mar 20 #Python
Python回文字符串及回文数字判定功能示例
Mar 20 #Python
python如何把嵌套列表转变成普通列表
Mar 20 #Python
Python内置函数reversed()用法分析
Mar 20 #Python
shell命令行,一键创建 python 模板文件脚本方法
Mar 20 #Python
python如何拆分含有多种分隔符的字符串
Mar 20 #Python
Python中str.join()简单用法示例
Mar 20 #Python
You might like
php中单个数据库字段多列显示(单字段分页、横向输出)
2014/07/28 PHP
redirect_uri参数错误的解决方法(必看)
2017/02/16 PHP
PHP连接MySQL数据库的三种方式实例分析【mysql、mysqli、pdo】
2019/11/04 PHP
javascript Split方法,indexOf方法、lastIndexOf 方法和substring 方法
2009/03/21 Javascript
javascript自定义startWith()和endWith()的两种方法
2013/11/11 Javascript
jquery datepicker参数介绍和示例
2014/04/15 Javascript
jQuery动态创建html元素的常用方法汇总
2014/09/05 Javascript
jquery插件jquery.nicescroll实现图片无滚动条左右拖拽的方法
2015/08/10 Javascript
详解javascript传统方法实现异步校验
2016/01/22 Javascript
轻松搞定js表单验证
2016/10/13 Javascript
微信小程序 选择器(时间,日期,地区)实例详解
2016/11/16 Javascript
Bootstrap3 多选和单选框(checkbox)
2016/12/29 Javascript
JS 组件系列之 bootstrap treegrid 组件封装过程
2017/04/28 Javascript
fullPage.js和CSS3实现全屏滚动效果
2017/05/05 Javascript
JS库之Particles.js中文开发手册及参数详解
2017/09/13 Javascript
Angular自定义组件实现数据双向数据绑定的实例
2017/12/11 Javascript
在vue中多次调用同一个定义全局变量的实例
2018/09/25 Javascript
typescript nodejs 依赖注入实现方法代码详解
2019/07/21 NodeJs
JavaScript HTML DOM 元素 (节点)新增,编辑,删除操作实例分析
2020/03/02 Javascript
Python实现基于权重的随机数2种方法
2015/04/28 Python
构建Python包的五个简单准则简介
2015/06/15 Python
Pandas统计重复的列里面的值方法
2019/01/30 Python
详解python中的index函数用法
2019/08/06 Python
pycharm中leetcode插件使用图文详解
2020/12/07 Python
Sunglasses Shop英国:欧洲领先的太阳镜在线供应商之一
2018/09/19 全球购物
大学生自我鉴定书
2014/03/24 职场文书
鉴定评语大全
2014/05/05 职场文书
禁烟标语大全
2014/06/11 职场文书
商务经理岗位职责
2014/07/30 职场文书
党的群众路线教育实践活动心得体会(乡镇)
2014/11/03 职场文书
个人自荐书范文
2015/03/09 职场文书
2015年禁毒工作总结
2015/04/30 职场文书
第二次离婚起诉书
2015/05/18 职场文书
关于元旦的广播稿2016
2015/12/17 职场文书
导游词之广州陈家祠
2019/10/21 职场文书
python使用shell脚本创建kafka连接器
2022/04/29 Python