How can I fix an error installing mysqlclient on CloudLinux?

Viewed 774

I'm trying to deploy my flask application on a cpanel with CloudLinux license, I need some modules, but when I try to install mysqlclient and flask-mysqldb I get errors, I have seen that people have a lot of problems with this module and I have seen how to fix it but in Ubuntu, Debian, etc... and I would like to know how to fix it in CloudLinux, here is the error when I type pip install mysqlclient:

 ERROR: Command errored out with exit status 1:
   command: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import                                                                                                              sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlcli                                                                                                             ent/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/mysqlclient/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-opkxp_ee
       cwd: /tmp/pip-install-oenqn_iu/mysqlclient/
  Complete output (29 lines):
  /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown                                                                                                              distribution option: 'long_description_content_type'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
  creating build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/co                                                                                                             nstants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/cons                                                                                                             tants
  copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constant                                                                                                             s
  copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constant                                                                                                             s
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/                                                                                                             constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/consta                                                                                                             nts
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/MySQLdb
  /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -Wno-unused-result -Wsign-compa                                                                                                             re -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURC                                                                                                             E -fPIC -fwrapv -fPIC -Dversion_info=(2,0,1,'final',0) -D__version__=2.0.1 -I/us                                                                                                             r/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python38/include/python3.8 -c                                                                                                              MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or dir                                                                                                             ectory
  error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status                                                                                                              1
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient

DEPRECATION: Could not build wheels for mysqlclient which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

 ERROR: Command errored out with exit status 1:
     command: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/mysqlclient/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-jckn3ad2/install-record.txt --single-version-externally-managed --compile --install-headers /home/clouxlla/virtualenv/flask/3.8/include/site/python3.8/mysqlclient
         cwd: /tmp/pip-install-oenqn_iu/mysqlclient/
    Complete output (29 lines):
    /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
    creating build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/MySQLdb
    /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,1,'final',0) -D__version__=2.0.1 -I/usr/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python38/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/mysqlclient/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-jckn3ad2/install-record.txt --single-version-externally-managed --compile --install-headers /home/clouxlla/virtualenv/flask/3.8/include/site/python3.8/mysqlclient Check the logs for full command output.

What should I do? Thanks you all in advance.

1 Answers

MySQL provides their own version of MySQL adapter - MySQL connector, an all-in python module that uses MySQL API with no C modules dependencies and only standard python modules used.

It works inside the CloudLinux CageFS without the installation of any modules or modifications of any configs.

You may read more about it here: https://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html

Related