Linux下安装mysql-python组件

  1. 下载mysql-python
    官网地址
  2. 解压
  3. 安装前的准备工作
    a、修改setup_posix.py中mysql_config.path为你mysql安装目录的mysql_config路径
[root@localhost blog]# whereis  mysql_config
mysql_config: /usr/bin/mysql_config /usr/share/man/man1/mysql_config.1.gz
修改mysql_config.path为你mysql安装目录的mysql_config路径如下:
mysql_config.path ="/usr/bin/mysql_config"
b、修改site.cfg
mysql_config = /usr/bin/mysql_config

c、执行命令:
export LD_LIBRARY_PATH=/usr/lib/mysql
ln -s /usr/lib/libmysqlclient.so            /usr/lib/libmysqlclient.so.16
ldconfig

4.build和install

  python setup.py build

如果出现
这里写图片描述
则CenOS和redhat可配置yum源安装python-dev

[root@localhost MySQL-python-1.2.2]# yum install python-devel.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check

ubuntu可以采用

sudo apt-get install python-dev

然后重复上述步骤
最后

setup.cfg  setup.py   
[root@localhost MySQL-python-1.2.2]# python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO

5、测试安装是否成功

你可能感兴趣的:(python)