当我尝试通过 pip 安装 mysqlclient 时,仅在 C99 模式错误中才允许遇到“for”循环初始声明

时间:2020-12-18 18:22:58

标签: python

由于以下错误,我无法通过 pip3 安装 Python mysqlclient 库

$ pip3.6 install mysqlclient
...
MySQLdb/_mysql.c: In function ‘_mysql_row_to_dict_cached’:
MySQLdb/_mysql.c:1340:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (unsigned int i=0; i

The OS is CentOS Linux release 7.7.1908 (Core), the gcc version is shown below

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 个答案:

答案 0 :(得分:0)

我不得不安装一个新的 gcc 版本,不幸的是标准存储库中不存在该软件包,我不得不将软件集合存储库添加到系统中,有关如何执行此操作的详细帖子可以在 {{3} }.


    yum install centos-release-scl -y
    yum install devtoolset-7-gcc* -y
    scl enable devtoolset-7 bash
    pip3 install mysqlclient