在Python 2.7.5环境pip安装MySQL-python模埠出现mysql_config not found报错:
[root@bogon ~]# pip install MySQL-python
Collecting MySQL-pythonDownloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 40kB/s
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-m1fwDF/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
原因是需要还需要安装mysql相关组件 mysql-devel,执行以下命令
[root@bogon ~]# yum -y install mysql-devel
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 2.9 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): extras/primary_db | 205 kB 00:00:00
(2/2): updates/primary_db | 6.0 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.60-1.el7_5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================
Installing:
mariadb-devel x86_64 1:5.5.60-1.el7_5 updates 754 k
Transaction Summary
=============================================================================================================================================================================
Install 1 Package
Total download size: 754 k
Installed size: 3.3 M
Downloading packages:
mariadb-devel-5.5.60-1.el7_5.x86_64.rpm | 754 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:mariadb-devel-5.5.60-1.el7_5.x86_64 1/1
Verifying : 1:mariadb-devel-5.5.60-1.el7_5.x86_64 1/1
Installed:
mariadb-devel.x86_64 1:5.5.60-1.el7_5
Complete!
安装完mysql-devel后再执行pip install MySQL-python后,安装成功
[root@bogon ~]# pip install MySQL-python
Collecting MySQL-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
Running setup.py bdist_wheel for MySQL-python ... done
Stored in directory: /root/.cache/pip/wheels/07/d2/5f/314860e4cb53a44bf0ee0d051d4b34465e4b4fbe9de6d42f42
Successfully built MySQL-python
Installing collected packages: MySQL-python
Successfully installed MySQL-python-1.2.5