Reputation: 274
I have just created a virtual environment on my machine (I am running on ubuntu 18.04 LTS). I have the python version of 3.6.7 and now I want to install mysqlclient into my virtual environment.
After I do pip install mysqlclient
it didn't work, instead it gave me errors saying;
Command "python.py egg_info" failed with error code 1 in /tmp/pip-install-zd21vfb3/mysqlclient/', and that the msql_config file is not found.
My setup tools are all up to date.
Upvotes: 10
Views: 21163
Reputation: 31
You need to install certain prerequisite packages to install mysqlclient
.
As of mysqlclient==2.2.4
, you need to install these packages:
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config
You can always refer to this mysqlclient GitHub link to keep up with the prerequisites.
Upvotes: 0
Reputation: 666
I was getting the same error when building my docker container. I tried installing the following in sequence but did not work.
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev
Then this 👇 solved the problem.
sudo apt-get install default-libmysqlclient-dev
Upvotes: 4
Reputation: 921
In order to correctly install MySQLClient on a fresh Ubuntu 18.04 LTS you need to install each of the following:
# Replace python3.6 with which ever version of Python3 you are using
sudo apt-get install python3.6-dev
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev
The last one is often missed on answers but is required now.
Only then can you install it via pip. Also make sure to update pip so you are not using version 9 if that installs into your vevn.
Upvotes: 14
Reputation: 1107
Check if you have already installed setuptools. After that in terminal
sudo apt-get install libmysqlclient-dev
Then(Keeping in mind to activate the virtual enviroment)
sudo pip3 install mysqlclient
Upvotes: 3
Reputation: 14761
mysqlclient
has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get
to install a couple of mysql packages.
In your case, it looks like the missing mysql_config
might be missing on your system. You can fix that by installing libmysqlclient-dev
on ubuntu bionic.
Upvotes: 27