Python Install Mysqlclient Keeps on Giving Error

Python Install Mysqlclient Keeps on Giving Error

From a list of the following dependencies present in a requirements.txt file

asgiref==3.2.7
astroid==2.4.1
colorama==0.4.3
Django==3.0.6
djangorestframework==3.11.0
djangorestframework-simplejwt==4.4.0
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
mysqlclient==1.4.6
PyJWT==1.7.1
pylint==2.5.2
pytz==2020.1
six==1.15.0
sqlparse==0.3.1
toml==0.10.1
wrapt==1.12.1

when I run

pip install -r requirements.txt

or

pip3 install -r requirements.txt

keep on getting the following error

If I follow this procedure by removing mysqlclient==1.4.6 from the requirements.txt file and try

sudo apt-get install mysqlclient

I get

E: Unable to locate package mysqlclient

4

2 Answers

In order to fix it, I had to run first

sudo apt-get install python-dev default-libmysqlclient-dev

and

sudo apt-get install python3-dev

and only then install the requirements.

Apparently, it was some silly issue related to gcc.

sudo apt install gcc

The above command should fix everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.