Error while install MySQLClient package cPanel terminal.
I am windows user and it’s run on windows completely but when upload to cPanel and install mysqlclient it not working
Error which i get in cpanel terminal
- ((project:3.8)) [shriyamc@callisto project]$ pip install mysqlclient
> Collecting mysqlclient Using cached mysqlclient-2.1.1.tar.gz (88 kB)
> Preparing metadata (setup.py) … done Building wheels for collected
> packages: mysqlclient Building wheel for mysqlclient (setup.py) …
> error error: subprocess-exited-with-error
>
> × python setup.py bdist_wheel did not run successfully. │ exit
> code: 1 ╰─> [40 lines of output] > mysql_config –version
> [‘10.5.20’] > mysql_config –libs
> [‘-L/usr/lib64’, ‘-lmariadb’, ‘-pthread’, ‘-ldl’, ‘-lm’, ‘-lpthread’, ‘-lssl’, ‘-lcrypto’, ‘-lz’] > mysql_config –cflags
> [‘-I/usr/include/mysql’, ‘-I/usr/include/mysql/..’] > ext_options:
> library_dirs: [‘/usr/lib64’] > libraries: [‘mariadb’, ‘dl’, ‘m’, ‘pthread’] > extra_compile_args: [‘-std=c99’] > extra_link_args: [‘-pthread’] > include_dirs: [‘/usr/include/mysql’, ‘/usr/include/mysql/..’] > extra_objects: [] > define_macros: [(‘version_info’, "(2,1,1,’final’,0)"), (‘version‘, ‘2.1.1’)] > running bdist_wheel
> running build
> running build_py
> creating build
> creating build/lib.linux-x86_64-cpython-38
> creating build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/init.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/exceptions.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-38/MySQLdb
> creating build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-38/MySQLdb/constants
> running build_ext
> building ‘MySQLdb.mysql’ extension
> creating build/temp.linux-x86_64-cpython-38
> creating build/temp.linux-x86_64-cpython-38/MySQLdb
> gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -pthread -Wno-unused-result -Wsign-compare -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -pthread -Wno-unused-result -Wsign-compare -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -O2 -pthread -Wno-unused-result -Wsign-compare -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -Dversion_info=(2,1,1,’final’,0) -D__version=2.1.1 -I/usr/include/mysql -I/usr/include/mysql/.. -I/home/shriyamc/virtualenv/project/3.8/include -I/opt/alt/python38/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-38/MySQLdb/_mysql.o -std=c99
> error: command ‘/bin/gcc’ failed: Permission denied
> [end of output] >
> note: This error originates from a subprocess, and is likely not a
> problem with pip. ERROR: Failed building wheel for MySQL client
> Running setup.py clean for mysqlclient Failed to build mysqlclient
> ERROR: Could not build wheels for mysqlclient, which is required to
> install pyproject.toml-based projects
>
2
Answers
As described in cpanel
cPanel, L.L.C. doesn’t develop or ship Python WSGI web applications,...
. when usingpip install mysqlclient
pip try to build mysqlclient package into a wheel but it is not a wheel .one way you can install the required dependencies from apt-get (Debian/ Ubuntu) or yum (Red Hat/ CentOS) :
then run
pip install mysqlclient
if it didn’t work go with mysql-connector-python :
I encountered a similar challenge while installing
mysqlclient
for my Django project on cPanel, and after facing issues, I found a workaround that might help you too.Instead of using
mysqlclient
, consider using thepymysql
module. Follow these steps:Install the pymysql module by running:
In your main Django settings file, add the following lines at the top:
This configuration allows Django to use pymysql as a substitute for
mysqlclient
. Following these steps, I successfully configured my Django project to connect to a MySQL database.You can also check out this video tutorial. It guided me through the process, and I hope it proves helpful for you too!
Note: Unlike some web service providers, it might not be necessary to run
sudo
commands for this solution, as it could be restricted by the hosting environment.