python之Linux开发环境安装

今天安装python的mysql API的时候遇到问题

[root@db MySQL-python-1.2.5]# python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    metadata, options = get_config()
  File "/root/code/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/root/code/MySQL-python-1.2.5/setup_posix.py", line 25, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

centos下解决该问题的方法

 

1,安装mysql-devel包

[root@db ~]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm 
warning: MySQL-devel-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]

 

2,cannot find -lmysqlclient

解决办法:

将mysql 安装目录lib文件下的libmysqlclient.so 建立软链接到lib64下

 

3,mysql_conf文件

报错: EnvironmentError: mysql_config not found

解决办法:

在mysql-python源码包下找到:setup_posix.py 文件,将第26行中的 mysql_config.path 将其值改为:/usr/bin/mysql_config

注意:mysql_config是命令而非mysql的配置文件

 

4,错误:ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
解决办法:
将mysql 安装目录lib文件下的libmysqlclient.so.18 建立软链接到lib64下

 

END!

你可能感兴趣的:(python之Linux开发环境安装)