安装新的python3.7还是报错

来源:4-9 打造高可用flask mvc框架

慕丝0417419

2020-12-26

(imooc_env) [root@localhost order]# pip install mysqlclient
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mysqlclient
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0e/68/f79de0e0fcdb041783124b825771e0ba6a3d0893b7b4c4735f130e42af47/mysqlclient-2.0.2.tar.gz (88 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /root/imooc_env/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/setup.py’"’"’; file=’"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-cjjjf1eo
cwd: /tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/
Complete output (31 lines):
running bdist_wheel
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 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Dversion_info=(2,0,2,‘final’,0) -D__version
=2.0.2 -I/usr/include/mysql -I/root/imooc_env/include -I/usr/local/python3/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o -m64
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<n; i++) {
^
MySQLdb/_mysql.c:1340:5: note: use option -std=c99 or -std=gnu99 to compile your code
error: command ‘gcc’ failed with exit status 1

ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient … error
ERROR: Command errored out with exit status 1:
command: /root/imooc_env/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/setup.py’"’"’; file=’"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/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-ubhah44e/install-record.txt --single-version-externally-managed --compile --install-headers /root/imooc_env/include/site/python3.7/mysqlclient
cwd: /tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/
Complete output (31 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 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Dversion_info=(2,0,2,‘final’,0) -D__version
=2.0.2 -I/usr/include/mysql -I/root/imooc_env/include -I/usr/local/python3/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o -m64
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<n; i++) {
^
MySQLdb/_mysql.c:1340:5: note: use option -std=c99 or -std=gnu99 to compile your code
error: command ‘gcc’ failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /root/imooc_env/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/setup.py’"’"’; file=’"’"’/tmp/pip-install-k39yg_y2/mysqlclient_3dec41fc224644668bc682ee7d1e4d06/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-ubhah44e/install-record.txt --single-version-externally-managed --compile --install-headers /root/imooc_env/include/site/python3.7/mysqlclient Check the logs for full command output.
WARNING: You are using pip version 20.3.1; however, version 20.3.3 is available.
You should consider upgrading via the ‘/root/imooc_env/bin/python -m pip install --upgrade pip’ command.
(imooc_env) [root@localhost order]#

写回答

1回答

编程浪子

2020-12-27

你好

你这个很麻烦,你按照下面的方式

操作下

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


参考文章:https://stackoverflow.com/questions/65362111/encountering-for-loop-initial-declarations-are-only-allowed-in-c99-mode-error 

0
0

Python Flask构建微信小程序订餐系统(可用于毕设)

微信小程序 + Python Flask 打造订餐系统全栈应用,可用于毕设。

1709 学习 · 1889 问题

查看课程