- Install dependencies
sudo apt-get build-dep python-mysqldb
- Install MySQLdb with pip/virtualenv
cd ~/lib/python-environments virtualenv --distribute --no-site-packages default pip install -E default/ MySQL-python
EnvironmentError: mysql_config not found
The first time, I did not install the dependencies and got the following error:
$ pip install -E default/ http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download Downloading/unpacking http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download Downloading download (89Kb): 89Kb downloaded Running setup.py egg_info for package from http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download sh: mysql_config: not found Traceback (most recent call last): File "
", line 14, in File "/tmp/pip-ZR_ZwM-build/setup.py", line 15, in metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found Complete output from command python setup.py egg_info: sh: mysql_config: not found Traceback (most recent call last): File " ", line 14, in File "/tmp/pip-ZR_ZwM-build/setup.py", line 15, in metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found ---------------------------------------- Command python setup.py egg_info failed with error code 1 Storing complete log in ./pip-log.txt
- How to use pip with crate.io — posted 2012-10-24
- How to install pip on Ubuntu — posted 2010-02-15
- Using psycopg2 with virtualenv on Ubuntu
JauntyMaverick — posted 2009-07-31
- Notes on using pip and virtualenv with Django — posted 2009-05-06
- Installing Python 2.6 from source on Ubuntu Hardy — posted 2008-10-02
Thank you - was running into that same error using easy_install
pip install -E worked like a charm
What is the cause of this happening?
i recently upgraded mysql with ubuntus upgrade manager, and it seems to have broken python-mysqldb
i tried your steps above but it did not work for me.
How many times does this blog save my day. Answer: all of them. All of the times.
Thank you. Just starting out, and I've depended on two of your posts in one day to get going. Great work.
Thanks this post and the other covering virtualenv helped me out a lot.
I ran into the same problem, and lost a few minutes, because the python-dev package was not installed. For the record.
Thanks for the sharing!!!! I suspect it was the build-dep part I was missing. My dog thanks you too, because I had to fix this before I could throw the ball for him.
Thank you; I had the same error without build-dep.
I believe it would be better to add the path to mysql_config to your PATH environment variable. This way you don't have to modify any files in the downloaded MySQL-python package.
I was using pip on OSX 10.7 and it could not find mysql_config, which is in /usr/local/mysql/bin/ (if you installed MySQL using the DMG installer) so I added this to PATH in my bin/activate script:
_OLD_VIRTUAL_PATH="$PATH" PATH="$VIRTUAL_ENV/bin:$PATH" PATH="$PATH:/usr/local/mysql/bin/" export PATH
You could also add some code to bin/activate that would search the system for common places that mysql_config can be found.
Thanks, I was stuck on this exactly.
I've installed python-dev package and it worked for me
sudo apt-get install mysql-server mysql-client libmysqlclient15-dev python-dev
pip install -E mysql-python
Great info. Worked like a charm!
Thanks so much installing dependencies worked
I'm using pip in virtualenv on OS X (10.7) with MySQL installed via macports.
My issue was macports suffixed
Solution for me:
sudo ln -s /opt/local/bin/mysql_config5 /opt/local/bin/mysql_config
Hope that helps anyone else in a similar situation.
This also works on Precise Pangolin (12.04). Weird.
pip install -E default/ MySQL-python ... no such option: -E
It works! Thanks!
just do these steps.....
1.sudo apt-get install libmysqlclient-dev
2.pip install flask-MySQLdb
these have worked for me .... hope it will work for you as well