百度教程說安裝
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
給兩個下載地址:http://download.csdn.net/detail/weibin0320/6663763
或者:http://www.jb51.net/softs/73369.html#download
安裝后再次執行install 命令。ok,沒有報錯。我們測試一下。
import MySQLdb
沒有報錯,安裝成功。。