【python】mysqldb Windows安装
来源:互联网 发布:gre单词书推荐 知乎 编辑:程序博客网 时间:2024/05/22 17:11
针对数据验证的项目,计划使用python实现一个sql查询原始数据验证数据正确性的小工具
原本电脑中有python2.7,现在得下载mysqldb模块,下载路径可在http://www.codegood.com/downloads,下载了MySQL-python-1.2.3.win-amd64-py2.7版本
接下来开始进行安装,点击安装出现了问题
搜索一下 Python version 2.7 required, which was not found in the registry 这个问题如何解决,发现此问题是由于安装的时候不能在注册表中识别出来python2.7,网上有脚本对注册表进行写入
## script to register Python 2.0 or later for use with win32all# and other extensions that require Python registry settings## written by Joakim Loew for Secret Labs AB / PythonWare## source:# http://www.pythonware.com/products/works/articles/regpy20.htm## modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.htmlimport sysfrom _winreg import *# tweak as necessaryversion = sys.version[:3]installpath = sys.prefixregpath = "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()
运行.py文件后,可自动识别python2.7。当然,此问题也可以直接修改注册表键值
- 打开注册表:win+R调出运行模块,输入regedit 打开注册表编辑器
- python的第三方安装模块一般默认在HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath路径下
- 添加HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath路径下的值
数值为python的安装路径
同样可进行安装
安装成功后,在编译器中import MySQLdb
,运行后发现,运行ERROR
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序
因为本地系统为64位系统,觉得是否是pythondb的版本安装有误,重新在另外的网站下载了64位的pythondb,发现仍提示此错误
查看一下本地的python
发现python竟然是32bit
重新下载32bit的pythondb,再次运行,成功
0 0
- Python 安装 MYSQLdb windows
- 【python】mysqldb Windows安装
- Windows下Python安装MySQLdb
- windows python MySQLdb 安装配置
- windows 下安装 python 的 mysqldb 模块
- Windows上搭建Python安装包MySQLdb
- windows 8 python安装MySQLdb模块
- Windows下安装Python数据库模块--MySQLdb
- python安装MySQLdb模块-(ubuntu,windows)
- windows下安装python MySQLdb及问题解决
- windows下python 安装mysqldb模块
- Windows下MySQLdb安装
- windows 安装MySQLdb
- MySQLdb for python 安装
- 安装 mysqldb for python
- python 安装MySQLdb模块
- 安装MySQLdb模块-python
- MySQLdb python模块安装
- Google官方MVP+Dagger2架构详解
- oracle如何删除用户
- hibernate 实体类xml配置
- Android应用开发学习笔记04--使用布局
- 4412驱动-poll 阻塞
- 【python】mysqldb Windows安装
- 简称ag的the_silver_searcher介绍,搜索代码神器
- linux操作
- 关于jquery使用live()方法的问题Uncaught TypeError: $(...).live is not a function
- 琐碎的区间(线段树区间更新 + 技巧!)
- 分布式消息系统 Kafka源码安装
- python项目练习一:即时标记
- Protobuf 有没有比 JSON 快 5 倍?
- POJ 1018. Communication System 动态规划解法