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

eor*_*ena 3 python

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

\n
$ pip3.6 install mysqlclient\n...\nMySQLdb/_mysql.c: In function \xe2\x80\x98_mysql_row_to_dict_cached\xe2\x80\x99:\nMySQLdb/_mysql.c:1340:5: error: \xe2\x80\x98for\xe2\x80\x99 loop initial declarations are only allowed in C99 mode\n     for (unsigned int i=0; i
Run Code Online (Sandbox Code Playgroud)\n

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

\n
$ gcc --version\ngcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)\nCopyright (C) 2015 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n
Run Code Online (Sandbox Code Playgroud)\n

eor*_*ena 6

我必须安装新的 gcc 版本,不幸的是标准存储库中不存在该软件包,并且我必须将 Software Collections 存储库添加到系统中,可以在此处找到有关如何执行此操作的详细帖子。


    yum install centos-release-scl -y
    yum install devtoolset-7-gcc* -y
    scl enable devtoolset-7 bash
    pip3 install mysqlclient
Run Code Online (Sandbox Code Playgroud)