python2.7.9安装mysql-python模块

我使用的系统版本是: SLES12-sp2

使用python连接Mysql数据库,需要安装mysql-python模块;

1. 首先安装pip:

从python官方网站下载get-pipe.py,执行这个脚本,就可以自动安装(或升级)

2.执行命令:

pip install mysql-python

报错:

_mysql.c:29:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

是因为没有安装python-devel这个软件包;

SUSE ENTERPRISE 12 SP 2 系统自带python版本是2.7.9, 找到合适的对应版本破费周折,到网上了找了一天,都没有结果;

最后在这个地址找到了:

https://ftp.internet.de/pub/linux/suse/sdk12sp2/suse/x86_64/

下载:python-devel-2.7.9-24.2.x86_64.rpm

装上它,然后重新执行pip install mysql-python就OK!

原文地址:https://www.cnblogs.com/ralphdc/p/7629135.html