Skip to main content
 首页 » 编程设计

python之在 linux AMI 上安装 MySQLdb Python 模块时出现问题

2024年08月30日23xxx_UU

我正在尝试使用 mysql(5.1 或更高版本)、python(2.6 或更高版本)和 mysqldb python 模块在 ec2 中设置 linux ami。有 2 个选项,从头开始或解决我已经开始的问题。

如果从头开始最简单,您能推荐一个 ami 和相关命令来进行此配置吗?

这是我尝试过的。我从这个 ami 开始:LAMP_Rails_Python_plus_goodies (ami-5db76434)。这给了我 mysql 和 python。我有 mysqldb 模块,但我相信它需要 python-devel 包。我尝试使用以下方法安装它:

yum 安装 python-devel

结果是:

Transaction Check Error: 
  file /etc/rpm/macros.python from install of python-1:2.6-2.22.amzn1.noarch conflicts with file from package system-release-2011.09-2.3.noarch 

这就是我卡住的地方。我不知道如何解决这个冲突。构建 mysqldb 模块(python setup.py 构建)导致:

In file included from _mysql.c:29: 
pymemcompat.h:10:20: error: Python.h: No such file or directory 
_mysql.c:30:26: error: structmember.h: No such file or directory 
_mysql.c:36:23: error: my_config.h: No such file or directory 
_mysql.c:38:19: error: mysql.h: No such file or directory 
_mysql.c:39:26: error: mysqld_error.h: No such file or directory 
_mysql.c:40:20: error: errmsg.h: No such file or directory 
_mysql.c:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 

谷歌搜索让我相信我需要安装 python-devel。也许我应该使用不同的 ami,但我觉得此时我正在玩猜谜游戏。感谢您的帮助。

请您参考如下方法:

在运行 yum install python-devel 之前运行 yum update -y 它应该正确安装(没有事务检查错误)。