Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centos7 pip3 install mysqlclient error: command '/usr/bin/gcc' failed with exit code 1 #157

Open
daifengqi opened this issue Dec 15, 2020 · 1 comment

Comments

@daifengqi
Copy link

Python version is 3.9.0

MySQL is mysql80-community-release-el7-3.noarch.rpm

ERROR: Command errored out with exit status 1:
     command: /home/cesc/envme/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7imlhj3_/mysqlclient_4abebc3dfb814f09b6c8b217e744025e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7imlhj3_/mysqlclient_4abebc3dfb814f09b6c8b217e744025e/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-usi8p1fw/install-record.txt --single-version-externally-managed --compile --install-headers /home/cesc/envme/include/site/python3.9/mysqlclient
         cwd: /tmp/pip-install-7imlhj3_/mysqlclient_4abebc3dfb814f09b6c8b217e744025e/
    Complete output (31 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.9
    creating build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.9/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.9/MySQLdb
    creating build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.9/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.linux-x86_64-3.9
    creating build/temp.linux-x86_64-3.9/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/home/cesc/envme/include -I/usr/local/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.9/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 '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/cesc/envme/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7imlhj3_/mysqlclient_4abebc3dfb814f09b6c8b217e744025e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7imlhj3_/mysqlclient_4abebc3dfb814f09b6c8b217e744025e/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-usi8p1fw/install-record.txt --single-version-externally-managed --compile --install-headers /home/cesc/envme/include/site/python3.9/mysqlclient Check the logs for full command output.

I've done these things

sudo yum install python3-devel mysql-devel gcc

I guess the problem may exist here

    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 '/usr/bin/gcc' failed with exit code 1

could you tell me how to run pip3 install with -std=c99 or any other solutions?

@daifengqi
Copy link
Author

However, it will success when specify the version:

pip3 install mysqlclient==1.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant