安装clickhouse-mysql 报错 error: ‘for’ loop initial declarations are only allowed in C99 mode
Running setup.py install for mysqlclient … error
ERROR: Command errored out with exit status 1:
command: /data1/soft/clickhouse-mysql/cmvenv/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-gc2jf4u3/mysqlclient_2744da51349a4078ac247bba4bde6b59/setup.py’"’"’; file=’"’"’/tmp/pip-install-gc2jf4u3/mysqlclient_2744da51349a4078ac247bba4bde6b59/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-v5s2wbi8/install-record.txt --single-version-externally-managed --compile --install-headers /data1/soft/clickhouse-mysql/cmvenv/include/site/python3.7/mysqlclient
cwd: /tmp/pip-install-gc2jf4u3/mysqlclient_2744da51349a4078ac247bba4bde6b59/
Complete output (29 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
creating build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb.mysql’ extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/MySQLdb
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Dversion_info=(2,0,2,‘final’,0) -D__version=2.0.2 -I/usr/local/mysql/include -I/data1/soft/clickhouse-mysql/cmvenv/include -I/usr/local/python3/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o -fabi-version=2 -fno-omit-frame-pointer
MySQLdb/_mysql.c: In function ‘_mysql_row_to_dict_cached’:
MySQLdb/_mysql.c:1340: error: ‘for’ loop initial declarations are only allowed in C99 mode
MySQLdb/_mysql.c:1340: note: use option -std=c99 or -std=gnu99 to compile your code
error: command ‘gcc’ failed with exit status 1
看报错日志为安装 mysqlclient时候报错。去github看解决方案为:
Can confirm CFLAGS="-std=c99" pip install mysqlclient works as a workaround.
链接为:
https://github.com/PyMySQL/mysqlclient/issues/460
最后安装成功