This guide is to indicate how to address the error “Failed building wheel for mysqlclient on cPanel”
Problem : Unable to install mysclientclient on cPanel #

Cause: GCC compiler is Disabled. #
So you’re trying to host your application on cPanel and you run into the error upon running the command pip install -r requirements.txt
where mysqlclient is one of the requirements.
Explanation #
Mysqlclient is a native database driver commonly used with Django applications.
When you try to install the package, python will try to build and compile the library.
Compilation of this package requires gcc
compiler which is required for installing Python modules that use C-libraries.
However gcc
compiler on our servers is disabled for cPanel user Accounts for security reasons.
As such compilation will fail.
Workaround or Alternatives #
1. Recommendation is to use a Python binding instead that will allow you to connect to your database.
Docs Mariadb: https://docs.djangoproject.com/en/5.1/ref/databases/#mariadb-notes
Docs Mysql : https://docs.djangoproject.com/en/5.1/ref/databases/#mysql-notes
On your requirements.txt
file remove mysqlclient
and replace it with pymysql
or mysql-connector-python
Then rerun pip install -r requirements.txt
again.
or
Just run pip install pymysql
or
Just run pip install mysql-connector-python
2. Alternatively, if you really need to use mysqlclient
, consider getting a VPS server that you will have full access to and as such compilation will work without issues.
Note: No change is required on your code.