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

來源:互聯網
上載者:User

標籤:root   zip   info   edit   pat   關係   imp   strong   x86   

要想使python可以操作mysql 就需要MySQL-python驅動,它是python 操作mysql必不可少的模組。

:https://pypi.python.org/pypi/MySQL-python/

下載MySQL-python-1.2.5.zip 檔案之後直接解壓。進入MySQL-python-1.2.5目錄:

python setup.py install

報錯:

[[email protected] MySQL-python-1.2.4]# python setup.py install

sh: mysql_config: command not found

Traceback (most recent call last):

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

    metadata, options = get_config()

  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

安裝成功。

 

[[email protected] 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沒多大關係,應該是缺少某些功能模組,然後Google了一下,先後安裝了python-devel,libffi-devel後還是不行,最後發覺要安裝openssl-devel才行

可如下命令列安裝:

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

 

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.