centos7 安裝mysql--python模塊出現EnvironmentError: mysql_config not found和error: command 'gcc' failed with

要想使python能夠操做mysql 就須要MySQL-python驅動,它是python 操做mysql必不可少的模塊。python

下載地址:https://pypi.python.org/pypi/MySQL-python/mysql

下載MySQL-python-1.2.5.zip 文件以後直接解壓。進入MySQL-python-1.2.5目錄:linux

python setup.py installsql

報錯:centos

[root@centos7 MySQL-python-1.2.4]# python setup.py installpython2.7

sh: mysql_config: command not foundcentos7

Traceback (most recent call last):.net

  File "setup.py", line 18, in <module>命令行

    metadata, options = get_config()orm

  File "/root/MySQL-python-1.2.4/setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "/root/MySQL-python-1.2.4/setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

網上查了一下需安裝mysql-devel 

#yum -y install mysql-devel 

安裝成功後

# python setup.py install

安裝成功。

 

[root@centos7 MySQL-python-1.2.5]# python

Python 2.7.5 (default, Jun 17 2014, 18:11:42) 

[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import MySQLdb

/usr/lib64/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/lib64/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc, but /root/MySQL-python-1.2.5 is being added to sys.path

 

 

用安裝Python模塊出現error: command 'gcc' failed with exit status 1 ,明明裝了gcc的,怎麼會不行呢,而後發覺是failed不是not found,這說明這個錯誤個gcc沒多大關係,應該是缺乏某些功能模塊,而後谷歌了一下,前後安裝了python-devel,libffi-devel後仍是不行,最後發覺要安裝openssl-devel才行

可以下命令行安裝:

yum install gcc libffi-devel python-devel openssl-devel

相關文章
相關標籤/搜索