Pip install mysql-python fails with EnvironmentError: mysql_config not found
Resolve EnvironmentError: mysql_config not found
. First, install MySQL development headers. Then, attempt pip install mysql-python
.
Behind the scenes of the error
Understanding the ruckus
The mysql_config
is required to compile the native C extensions for MySQL-python. If mia, the necessary MySQL dependencies remain unreachable.
Where's Waldo (mysql_config
)
Locate mysql_config using:
Navigating the labyrinthine system paths
Linux-based chameleons:
- Ubuntu/Debian: Libraries get hip with age. Use
default-libmysqlclient-dev
. Don't forget tosudo apt update
, keeps 'em fresh. - CentOS: Embrace both
python-devel
andmysql-devel
with ayum
hug.
macOS adventurers:
Adapt to alterations:
And/or take the universal plunge into /etc/paths
.
Securing the lot for installation
Bagging the essentials for MySQL-python
- Python headers: Get with
python-dev
or its cool cousinpython3-dev
. - MySQL client libraries: Gift-wrapped in
libmysqlclient-dev
.
Dealing in virtual environments
Keep the virtual veil activated before embracing mysql-python
.
Swapping to the MySQLdb support
Consider python-MySQLdb
, pre-baked and ready, no mysql_config
hunts.
Extra points if you can:
- Battling with OSX Mountain Lion, add its specific paths
- Exploring with pip3 for Python 3 installations
Smoothing out the chinks
Checking out the environment setup
mysql_config
being available is a thumbs-up sign for Python MySQL adventures.
Updating the System's memory
Keep the system in the know with sudo apt update
or yum update
before installing the latest versions of dependencies.
Wrangling macOS paths
For macOS diaspora, paths might need reconfiguring after updates to OS or MySQL.
Befriending Docker Containers
Dockerfiles should specify MySQL dependencies installation to mind the gap:
Was this article helpful?