I'm encountering this error when trying to update my mysqlclient install from 1.4.6 to 2.0.2. Looks like the gcc version is quite old? Any way to address this?
 
 gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
I can confirm this issue persists when I try to use system pip.
Installing dependencies from lock file
Package operations: 0 installs, 1 update, 0 removals
  • Updating mysqlclient (1.4.6 -> 2.0.2)
  EnvCommandError
  Command ['/home/opalstack-user/apps/django-appp/.venv/bin/pip', 'install', '--no-deps', '-U', 'file:///home/opalstack-user/.cache/pypoetry/artifacts/25/86/4e/4d65cec9eb782ebe942262954c52b022bdf470c94461b2a7b89f4faebc/mysqlclient-2.0.2.tar.gz'] errored with the following return code 1, and output:
  Processing /home/opalstack-user/.cache/pypoetry/artifacts/25/86/4e/4d65cec9eb782ebe942262954c52b022bdf470c94461b2a7b89f4faebc/mysqlclient-2.0.2.tar.gz
  Building wheels for collected packages: mysqlclient
    Building wheel for mysqlclient (setup.py): started
    Building wheel for mysqlclient (setup.py): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /home/opalstack-user/apps/django-appp/.venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2wk6v8dm/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2wk6v8dm/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-qmm1kiud
         cwd: /tmp/pip-req-build-2wk6v8dm/
    Complete output (31 lines):
    running bdist_wheel
    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/usr/include/mysql/mysql -I/home/opalstack-user/apps/django-appp/.venv/include -I/home/opalstack-user/.pyenv/versions/3.9.0/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.9/MySQLdb/_mysql.o
    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: Failed building wheel for mysqlclient
    Running setup.py clean for mysqlclient
  Failed to build mysqlclient
  Installing collected packages: mysqlclient
    Attempting uninstall: mysqlclient
      Found existing installation: mysqlclient 1.4.6
      Uninstalling mysqlclient-1.4.6:
        Successfully uninstalled mysqlclient-1.4.6
      Running setup.py install for mysqlclient: started
      Running setup.py install for mysqlclient: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /home/opalstack-user/apps/django-appp/.venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2wk6v8dm/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2wk6v8dm/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-yzmi7uk2/install-record.txt --single-version-externally-managed --compile --install-headers /home/opalstack-user/apps/django-appp/.venv/include/site/python3.9/mysqlclient
           cwd: /tmp/pip-req-build-2wk6v8dm/
      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/usr/include/mysql/mysql -I/home/opalstack-user/apps/django-appp/.venv/include -I/home/opalstack-user/.pyenv/versions/3.9.0/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.9/MySQLdb/_mysql.o
      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
      ----------------------------------------
    Rolling back uninstall of mysqlclient
    Moving to /home/opalstack-user/apps/django-appp/.venv/lib/python3.9/site-packages/MySQLdb/
     from /home/opalstack-user/apps/django-appp/.venv/lib/python3.9/site-packages/~ySQLdb
    Moving to /home/opalstack-user/apps/django-appp/.venv/lib/python3.9/site-packages/mysqlclient-1.4.6.dist-info/
     from /home/opalstack-user/apps/django-appp/.venv/lib/python3.9/site-packages/~ysqlclient-1.4.6.dist-info
  ERROR: Command errored out with exit status 1: /home/opalstack-user/apps/django-appp/.venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2wk6v8dm/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2wk6v8dm/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-yzmi7uk2/install-record.txt --single-version-externally-managed --compile --install-headers /home/opalstack-user/apps/django-appp/.venv/include/site/python3.9/mysqlclient Check the logs for full command output.
  WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
  You should consider upgrading via the '/home/opalstack-user/apps/django-appp/.venv/bin/python -m pip install --upgrade pip' command.
  at ~/.pyenv/versions/3.9.0/lib/python3.9/site-packages/poetry/utils/env.py:1074 in _run
      1070│                 output = subprocess.check_output(
      1071│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1072│                 )
      1073│         except CalledProcessError as e:
    → 1074│             raise EnvCommandError(e, input=input_)
      1075│
      1076│         return decode(output)
      1077│
      1078│     def execute(self, bin, *args, **kwargs):