Windows下安装Python数据库模块--MySQLdb
## 1、下载MySQLdb
[去官网](http://pypi.python.org/pypi/MySQL-python/)
下载对应的编译好的版本(现在官网最新版本为1.2.5):
MySQL-python-1.2.5.win32-py2.7.exe
得到1MB的安装文件
MySQL-python-1.2.5.win32-py2.7.exe
## 2、安装
以上版本目前只支持到python2.7,在安装MySQLdb之前确定你已经在电脑上安装了python27。
双击安装:
然后点下一步出现:
我确实已经安装了python 2.7
究其原因是因为此x86的exe,是不支持我的win7 x64。
## 3、源码安装
[下载源码] (https://pypi.python.org/pypi/MySQL-python/1.2.5)
然后再去解压和安装,结果果然出现错误:
error: Unable to find vcvarsall.bat
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.5\MySQL-python-1.2.4>setup.py install
Extracting in c:\users\cli\appdata\local\temp\tmpkapo0l
Now working in c:\users\cli\appdata\local\temp\tmpkapo0l\distribute-0.6.28
Building a Distribute egg in D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4\distribute-0.6.28-py2.7.egg
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
reading manifest file ‘MySQL_python.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘MySQL_python.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib.win-amd64-2.7
copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb__init__.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
creating build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants__init__.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\constants
running build_ext
building ‘_mysql’ extension
error: Unable to find vcvarsall.bat
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4>
然后参考之前的办法,结果还是出错:
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4>SET VS90COMNTOOLS=%VS100COMNTOOLS%
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4>setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
reading manifest file ‘MySQL_python.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘MySQL_python.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
running build_ext
building ‘_mysql’ extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,4,’final’,1) -D__version__=1.2.4 “-IC:\Program Files (x86)\MySQL\MySQL
Connector C 6.0.2\include” -ID:\tmp\dev_install_root\Python27_x64\include -ID:\tmp\dev_install_root\Python27_x64\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release_mysql.obj /Zl
_mysql.c
_mysql.c(42) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
error: command ‘”C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe”’ failed with exit status 2
D:\tmp\dev_tools\python\mysql\MySQL-python-1.2.4\MySQL-python-1.2.4>
然后再参考:
Windows下安装MySQLdb遇到的问题及解决方法
所说的:
1)问题 : _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2
原因 :原因是安装MySQL的时候没有安装C语言库。
解决 :重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。
Windows下安装Python数据库模块--MySQLdb的更多相关文章
- Windows下安装Python requests模块
在使用自己写的或者别人的python小工具时可能会出现类似ImportError: No module named Requests的问题: D:\tool\python\fuzz>Fuzz.p ...
- windows下安装python模块
如何在windows下安装python模块 1. 官网下载安装包,比如(pip : https://pypi.python.org/pypi/pip#downloads) pip-9.0.1.tar. ...
- linux和windows下安装python拓展包及requirement.txt安装类库
python拓展包安装 直接安装拓展包默认路径: Unix(Linux)默认路径:/usr/local/lib/pythonX.Y/site-packagesWindows默认路径:C:\Python ...
- 【转】linux和windows下安装python集成开发环境及其python包
本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...
- windows下安装python和依赖包的利器——Anaconda
在windows下安装python和很多依赖包,安装起来略为痛苦,可以使用python的大整合包——Anaconda Anaconda下载地址: http://continuum.io/downloa ...
- Windows下安装Python虚拟环境
Windows下安装Python虚拟环境 虚拟环境安装 需求概要 "虚拟环境"是从电脑独立开辟出来的环境.就好比我们生活中的橱柜中,会把酱油放在一个瓶子里,把醋放在另外一个瓶子里, ...
- Windows下安装python的scipy等科学计算包(转)
如果要使用python进行科学计算.数据分析等,一定要安装scipy.seaborn.numpy等等包. 但Windows下安装python的第三方库经常会出现问题.此前,已介绍过Windows下如何 ...
- windows下安装python、环境设置、多python版本的切换、pyserial与多版本python安装、windows命令行下切换目录
1.windows下安装python 官网下载安装即可 2.安装后的环境设置 我的电脑--属性--高级--设置path的地方添加python安装目录,如C:\Python27;C:\Python33 ...
- 在windows下安装python包管理器pip及使用
从来没有在Windows下用过pip,今天试了下,原来pip也可以在Windows下安装,使用也和Linux下一样简单. 先从下面的地址下载pip源码: http://pypi.python.or ...
随机推荐
- npm EPERM: operation not permitted, rename解决
此问题并非权限问题! 执行如下3条命令解决: 1.清理npm缓存 npm cache clean --force 2.升级npm版本 npm install -g npm@latest --force ...
- 从零开始的全栈工程师——JS面向对象(初篇)
面向对象编程 面向对象编程是用抽象方式创建基于现实世界模型的一种编程模式.它使用先前建立的范例,包括模块化,多态和封装几种技术.今天,许多流行的编程语言(如Java,JavaScript,C#,C+ ...
- CAD鼠标移动到对象时显示对象内容
//定义事件 Editor ed = doc.Editor; ed.PointMonitor += new PointMonitorEventHandler(ed_Po ...
- u-boot分析(十)----堆栈设置|代码拷贝|完成BL1阶段
u-boot分析(十) 上篇博文我们按照210的启动流程,分析到了初始化nand flash,由于接下来的关闭ABB比较简单所以跳过,所以我们今天按照u-boot的启动流程继续进行分析. 今天我们会用 ...
- Arm启动流程解析
谈到arm的启动流程不得不说的是bootloader,但是我这篇文章主要来谈谈arm启动流程的,所以bootloader只是跟大家简介一下就ok.这篇文章我会谈到以下内容: 1.bootloader简 ...
- [SVN]TortoiseSVN工具培训3─使用基本流程和图标说明
1.SVN的使用基本流程 注意:对于文件编辑方面,上图的编辑副本操作前建议进行Get lock操作,以防出现后续的冲突等异常报错. 2.SVN的基本图标说明
- 第四章 T-SQL编程
1.前言->此T-SQL编程是基于sql server开发环境->关键字:T-SQL编程:游标:视图和索引 2.T-SQL编程基础->标识符:常规标识符必须以汉字.字母.下划线_.@ ...
- 【转载】SQL执行计划
要理解执行计划,怎么也得先理解,那各种各样的名词吧.鉴于自己还不是很了解.本文打算作为只写懂的,不懂的懂了才写. 在开头要先说明,第一次看执行计划要注意,SQL Server的执行计划是从右向左看的. ...
- MySQL入门很简单: 5 索引
1. 索引的含义和特点 索引:创建在表上,是对数据库表中一列或多列的值进行排序的一种结构. 存储类型: B性树(BTREE)索引和哈希(HASH)索引: InnoDB和MyISAM支持BTREE索引, ...
- javascript当中的无限分类
var data = [ {id:100000, name :"1", pid :0}, {id:100100, name :"1-1", pid :10000 ...