python2.7 mysql.connector的安装
来源:互联网 发布:崩坏学园淘宝店名 编辑:程序博客网 时间:2024/06/06 03:43
将pyton2.7 mysql.connector安装心得写下,供其他网友参考
1.去官网http://dev.mysql.com/downloads/connector/python 下载了 mysql-connector-python-2.1.3-py2.7-win32.msi 这个版本的进行安装
安装时却出现:
百度了一下,说什么需要自己一个register.py:
import sys from _winreg import * # tweak as necessaryversion = 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()
可是运行显示:
再次失败。
2.我下载MySQL-python-1.2.5.win32-py2.7.exe 进行安装 ,安装 成功,但是些驱动的包是
import MYSQLdb
在网上查了一下,这个似乎被淘汰了。现在基本上都用mysql.connector
于是果断将其卸载,誓要将mysql.connector安装上
3.我换了个方向,不用官方的msi文件安装,想用源码来安装
果然在网上可以下载mysql.connector的源码 mysql-connector-python-1.2.3.zip
将其解压,看到了setup.py文件,那个激动呀,不说了
直接
python setup.py install
运行结果:
安装成功,文件写入了python2.7 安装目录下
看到有红色框的这两个文件,我就彻底安心了
运行 :>>python
>> import mysql.connector
完美,没有报错。
啦,啦,啦 ,到此,安装 成功
运行结果:
安装成功,文件写入了python2.7 安装目录下
看到有红色框的这两个文件,我就彻底安心了
运行 :>>python
>> import mysql.connector
完美,没有报错。
啦,啦,啦 ,到此,安装 成功
1 0
- python2.7 mysql.connector的安装
- python2.7 mysql.connector的安装
- win10,python2.7,mysql-connector-python 报错 mysql.connector.errors.InternalError: Unread result found
- Python2.7 with MySQL Connector/Python Sample(Windows OS)
- python2.7安装mysql的数据驱动
- mac 下安装python3 的mysql connector
- python mysql-connector的安装和使用
- mysql-connector-python安装
- Python:安装MYSQL Connector
- python2.7安装mysql驱动
- windows安装python的mysql驱动mysql-connector-python
- MySQL Connector/Python 安装、测试
- MySQL Connector/Python 安装、测试
- MySQL Connector/Python 安装、测试
- ubuntu安装mysql-connector-python
- ubuntu安装mysql-connector-python
- mysql-connector-pythonl驱动安装
- python安装mysql-connector-python
- eclipse插件OpenExplorer快速打开文件目录
- Linux系统修改文件读写权限chmod、所有者或组chown
- Qt含各种头文件和源文件的方法
- Vue.js的事件机制
- 人物观点——Richard Wilding:网络安全改革不会一蹴而就
- python2.7 mysql.connector的安装
- 关于textbox输入限制的一点小结
- 多线程——同步函数的锁的相关问题
- JAVA 如何手动修改tomcat启动端口
- 尼姆博弈的SG值计算简单模板
- Reids的简单使用
- java异常机制
- JavaScript引用类型
- 陕西省集训day1(枚举,贪心,二分)