1. 程式人生 > >python-MySQLdb接口程序安裝

python-MySQLdb接口程序安裝

程序 python import

centos 7,python2.7 安裝python-MySQLdb,因是最小化安裝,安裝過程中需要依賴其他的工具或包

[[email protected] ~]# pipinstall mysql-python

報錯:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-Gme83P/mysql-python/

通過yum 安裝以下兩個包;

[[email protected] ~]# yum install mysql-devel

[[email protected]

/* */ ~]# yum installpython-devel

再執行安裝,出現以下報錯,需要安裝gcc編譯工具,

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__=‘/tmp/pip-build-U2yiQI/mysql-python/setup.py‘;f=getattr(tokenize, ‘open‘, open)(__file__);code=f.read().replace(‘\r\n‘, ‘\n‘);f.close();exec(compile(code, __file__, ‘exec‘))" install --record /tmp/pip-iogwbL-record/install-record.txt --single-version-externally-managed --compile"failed with error code 1 in /tmp/pip-build-U2yiQI/mysql-python/

[[email protected] ~]#yum install gcc

安裝pip需要先裝setuptools
https://pypi.python.org/pypi/setuptools

[[email protected] setuptools-36.0.1]# pip install mysql-python

Collecting mysql-python

Using cached MySQL-python-1.2.5.zip

Installing collected packages: mysql-python

Running setup.py install for mysql-python ... done


本文出自 “沒有你的城市” 博客,謝絕轉載!

python-MySQLdb接口程序安裝