pip install MySQL-python 失败

时间:2020-12-16 14:34:27

1. EnvironmentError: mysql_config not found
原因:/usr/bin/mysql_config没有次文件,要安装libmysqlclient-dev, apt install libmysqlclient-dev -y 如果能安装上并且有了mysql_config此问题就可以解决了。如果libmysqlclient-dev 没有安装成功,提示:E: Unable to correct problems, you have held broken packages 先参考http://www.cnblogs.com/aaron-agu/p/8862624.html 安装好libmysqlclient-dev

2.  _mysql.c:29:20: fatal error: Python.h: No such file or directory
   #include "Python.h"
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
原因:python-dev 没有安装,如果apt-get install python-dev -y 可以成功安装,此问题解决,如果提示如下错误 python-dev : Depends: python (= 2.7.11-1) but 2.7.12-1~16.04 is to be installed
              Depends: libpython-dev (= 2.7.11-1) but it is not going to be installed
              Depends: python2.7-dev (>= 2.7.11-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages
此错误原因 python版本过高,aptitude install python-dev 类似http://www.cnblogs.com/aaron-agu/p/8862624.html的解决方案,降级。