Mac OS X - EnvironmentError: mysql_config not found
Ok, well, first of all, let me check if I am on the same page as you:
- You installed python
- You did
brew install mysql
- You did
export PATH=$PATH:/usr/local/mysql/bin
- And finally, you did
pip install MySQL-Python
(orpip3 install mysqlclient
if using python 3)
If you did all those steps in the same order, and you still got an error, read on to the end, if, however, you did not follow these exact steps try, following them from the very beginning.
So, you followed the steps, and you're still geting an error, well, there are a few things you could try:
Try running
which mysql_config
from bash. It probably won't be found. That's why the build isn't finding it either. Try runninglocate mysql_config
and see if anything comes back. The path to this binary needs to be either in your shell's $PATH environment variable, or it needs to be explicitly in the setup.py file for the module assuming it's looking in some specific place for that file.Instead of using MySQL-Python, try using 'mysql-connector-python', it can be installed using
pip install mysql-connector-python
. More information on this can be found here and here.Manually find the location of 'mysql/bin', 'mysql_config', and 'MySQL-Python', and add all these to the $PATH environment variable.
If all above steps fail, then you could try installing 'mysql' using MacPorts, in which case the file 'mysql_config' would actually be called 'mysql_config5', and in this case, you would have to do this after installing:
export PATH=$PATH:/opt/local/lib/mysql5/bin
. You can find more details here.
Note1: I've seen some people saying that installing python-dev
and libmysqlclient-dev
also helped, however I do not know if these packages are available on Mac OS.
Note2: Also, make sure to try running the commands as root.
I got my answers from (besides my brain) these places (maybe you could have a look at them, to see if it would help): 1, 2, 3, 4.
I hoped I helped, and would be happy to know if any of this worked, or not. Good luck.
pip install mysql-python fails with EnvironmentError: mysql_config not found
It seems mysql_config is missing on your system or the installer could not find it.
Be sure mysql_config is really installed.
For example on Debian/Ubuntu you must install the package:
sudo apt-get install libmysqlclient-dev
Maybe the mysql_config is not in your path, it will be the case when you compile by yourself
the mysql suite.
Update: For recent versions of debian/ubuntu (as of 2018) it is
sudo apt install default-libmysqlclient-dev
Mac pip install mysql-python unsuccessful
Please, try:
CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install -r requirements.txt
If it does not work:
First install mysql-connector-c
brew install mysql-connector-c
pip install MySQL-python
If you are using Windows:
https://dev.mysql.com/downloads/connector/c/
You can also check what happend when you try install it with pip3.
UPDATE:
If you have Linux:
Please open the /usr/local/bin/mysql_config
.
And then:
#Create options
Libs = "-L $ pkglibdir "
Libs = " $ libs -l"
replace with:
#Create options
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"
Save it and reinstall mysql-python
.
pip uninstall mysql-python
pip install mysql-python
For Mac:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python
should be helpful.
Related Topics
Is There Any Difference Between "Foo Is None" and "Foo == None"
Writing to Existing Workbook Using Xlwt
How to Calculate the Sum of All Columns of a 2D Numpy Array (Efficiently)
Link Atlas/Mkl to an Installed Numpy
Matplotlib and Ipython-Notebook: Displaying Exactly the Figure That Will Be Saved
Python Request Post with Param Data
Display Special Characters When Using Print Statement
Typeerror: Worker() Takes 0 Positional Arguments But 1 Was Given
Python Scope: "Unboundlocalerror: Local Variable 'C' Referenced Before Assignment"
Processing Single File from Multiple Processes
Python Global Exception Handling
How to Remove the Left Part of a String
Why Not Generate the Secret Key Every Time Flask Starts
How to Insert Newlines on Argparse Help Text