Windows 10 环境下python2.7 安装 mysql-python

环境:
Windows 10
Python 2.7
需要安装mysql-python相关模块

C:\Python27\Scripts>pip2 install MySQLdb
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting MySQLdb
Could not find a version that satisfies the requirement MySQLdb (from versions: )
No matching distribution found for MySQLdb
发现并不是 MySQLdb,而是mysql .

于是 需要下载驱动:
64位: MySQL-python-1.2.3.win-amd64-py2.7.exe
32位: MySQL-python-1.2.5.win32-py2.7.exe

在安装时遇到以下问题:
安装MySQL-python-1.2.3.win-amd64-py2.7.exe,时提示:Python version 2.7 required, which was not found in the registry
这是在注册表不能识别python2.7,原因windows是64位,安装的python是32位
备注: MySQLdb for python (32/64位)下载;http://www.codegood.com/archives/129 不同版本都有,选择自己需要的版本。

于是选择安装 MySQL-python-1.2.3.win-amd64-py2.7.exe ,待安装完成后,
pip2 install mysql (因为本机同时安装了Python 2.x 和Python 3.x)
C:\Python27\Scripts>pip2 install mysql

Requirement already satisfied: MySQL-python in c:\python27\lib\site-packages (from mysql) (1.2.3)
Installing collected packages: mysql
Running setup.py install for mysql … done
Successfully installed mysql-0.0.2

安装成功。

在python IDLE 中,检查是否安装成功。
import MySQLdb
不再报错,说明安装成功。

接下来,开始捡起python 操作数据库相关的脚本练习。

参考:https://blog.csdn.net/lcr_happy/article/details/73252819

你可能感兴趣的:(MySQL)