安装过程
[dm href=’https://pypi.python.org/pypi/MySQL-python’]下载地址[/dm]
下载解压,进入目录:
$ sudo python setup.py build $ sudo python setup.py install
报错处理
安装的时候可能会报错EnvironmentError: mysql_config not found
进行下面安装:
$ sudo apt-get install libmysqld-dev $ sudo apt-get install mysql-devel
安装完成之后:
find / -name mysql_config
查找到路径,把当前路径下的site.cfg修改mysql_config=(查找到的路径)
修改完成后再执行安装。
安装检查
$ python >>> import MySQLdb
可能会报错UserWarning: Module _mysql was already imported from
这个是讲当前存在和Python目录相同的包,重复导入。换一个目录再执行就好了。
可能会报错
UserWarning: /home/lee/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename
切换到/home/lee/文件夹下,执行:
chmod g-wx,o-wx .python-eggs/
Mac 安装MySQLdb 出现EnvironmentError: mysql_config not found错误
参考地址:http://stackoverflow.com/questions/25459386/mac-os-x-environmenterror-mysql-config-not-found
解决办法:
You installed python You did brew install mysql You did export PATH=$PATH:/usr/local/mysql/bin And finally, you did pip install MySQL-Python