标签:ref set use 数据 pac license more setup.py site
这个MySQLdb就是python操作MySQL数据库的模块
所以,你得先安装它,默认是没安装
一. 安装libmysqlclient-dev
#apt-get update
#apt-get install libmysqlclient-dev
二.安装setuptools
https://pypi.python.org/pypi/setuptools/
setuptools-36.7.0.zip
#unzip setuptools-36.7.0.zip
#cd setuptools-36.7.0
#python setup.py build
#python setup.py install
三.安装MySQL-python
https://pypi.python.org/pypi/MySQL-python/1.2.5
MySQL-python-1.2.5.zip
#cd MySQL-python-1.2.5
#vim setup_posix.py
修改mysql_config.path = “mysql_config"
为mysql_config.path = "/usr/bin/mysql_config"
#python setup.py build
#python setup.py install
四.验证
# python
Python 2.7.14 (default, Nov 1 2017, 00:48:15)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc, but /home/woodzcl/MySQL-python-1.2.5 is being added to sys.path
OK,已经正确安装python的MySql模块
标签:ref set use 数据 pac license more setup.py site
原文地址:http://www.cnblogs.com/woodzcl/p/7815970.html