windows下python操作mysql模块安装

pip install mysqldb

这在我的电脑上安装失败:

  Could not find a version that satisfies the requirement mysqldb (from versions
: )
No matching distribution found for mysqldb

所以应该:

pip install MySQL-python

报错:

error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27

缺少vc的一个库,我们根据提示到这里下载一下,然后安装,再次执行命令 :pip install mysql-python

还是报错:

No such file or directory
    error: command '"C:\Users\年浩\AppData\Local\Programs\Common\Microsoft\Visua
l C++ for Python\9.0\VC\Bin\amd64\cl.exe"' failed with exit status 2

这是因为缺少驱动。

MySQL-python-1.2.3.win-amd64-py2.7.exe(注意该驱动版本要和MySQL-python版本一致)

给两个下载地址:http://download.csdn.net/detail/weibin0320/6663763

或者:http://www.jb51.net/softs/73369.html#download

安装后再次执行install 命令。ok,没有报错。我们测试一下。

import MySQLdb

没有报错,安装成功。。


转自:http://www.cnblogs.com/superxuezhazha/p/6619036.html


猜你喜欢

转载自blog.csdn.net/weixin_37887248/article/details/80825243