First of all… not, it’s not a repeated thread. Believe me, I read all similar threads and tested all answers before post this.
I just have a new CentOS 7 server installation, with basic configuration (the same I used several times before, but magically, this time does not work)
yum -y update
yum -y groupinstall development
yum -y install gcc
yum -y install zlib-devel
yum -y install openssl-devel
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install mariadb-devel
Python3.6
yum -y install python36
yum -y install python36-devel
However, once I create my virtual environment with: python3 -m venv test
and try to install mysqlclient
using pip
… Simply doesn’t work. The error I have is:
ERROR: Command errored out with exit status 1:
command: /var/www/test/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pn9v4w46/mysqlclient_d62f41676e4049d6a292a9525c56d5c9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pn9v4w46/mysqlclient_d62f41676e4049d6a292a9525c56d5c9/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7ethj5wf/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/test/include/site/python3.6/mysqlclient
cwd: /tmp/pip-install-pn9v4w46/mysqlclient_d62f41676e4049d6a292a9525c56d5c9/
Complete output (31 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,2,'final',0) -D__version__=2.0.2 -I/usr/include/mysql -I/var/www/test/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -m64
MySQLdb/_mysql.c: En la función ‘_mysql_row_to_dict_cached’:
MySQLdb/_mysql.c:1340:5: error: sólo se permiten las declaraciones iniciales del bucle ‘for’ en modo C99
for (unsigned int i=0; i<n; i++) {
^
MySQLdb/_mysql.c:1340:5: nota: use la opción -std=c99 o -std=gnu99 para compilar su código
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /var/www/test/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pn9v4w46/mysqlclient_d62f41676e4049d6a292a9525c56d5c9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pn9v4w46/mysqlclient_d62f41676e4049d6a292a9525c56d5c9/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7ethj5wf/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/test/include/site/python3.6/mysqlclient Check the logs for full command output.
So… just for save us time, I already tried with all this libraries installed (just for test):
mysql-devel
, mysql-connector-python
, zlib.i686
, glibc.i686
, MySQL-python
, even installing mysql-server
. I mean… Because I can’t find a logic answer to this situation I just test to install any library I suspect could help, but nothig works. Always the same error.
As I said, I read every single post with errors similar to this, tutorials to configure MySQL on CentOS 7 with django, etc, etc, and all libraries people say in this posts, I tried, but error persist.
I’m into this situation because my hard disk died and I need to configure all my development server from scratch, and I run into this issue for almost a week. So… basically I’m a bit desperate 🙂
Thanks in advance
2
Answers
Issue is with version
2.0.2
and it is already reportedYou could downgrade package to version
2.0.1
or setCFLAG
to compile with C99 standardAs per this github issue, the latest release has some issues with centos7. Recommend solution is to use the previous version (2.0.1)