I got the below failure while trying to get MySQL-python installed on my Ubuntu/Linux Box.From the below it seem like the issue is
sh: mysql_config: not found Could someone advice me on what to do?
Active2 years, 3 months ago
MacPorts has a port for MySQLdb (py-mysql and variants). If Homebrew has a 'formula', I can't find it, but a pip install should work once you have compatible versions of Python and MySQL. The hard way The hard part about the Mac is, there are three architectures you could be building for: PowerPC, Intel 32-bit, and Intel 64-bit. This will attempt to install the drivers, but will fail.This is because the coders behind MySQL-python have failed to fix a very simple bug in types.h (1808476 – “#define of uint breaks compiling on Mac OS X 10.5”).
Install MySQL Connector Python on Windows, Linux, Unix, MacOs using PIP or using ZIP and TAR file. We can also install using MSI installer and RPM package.Prerequisites for installing MySQL Connector Python. MySQLdb is an api for accessing MySQL database using python. It is built on top of MySQL C API. MySQLdb don’t yet have support for python 3, it supports only python 2.4 – 2.7. As a result you need to use python 2 for this tutorial. We will be using python 2.7.9, which you can download from here. Installing MySQLdb.
user618677
user618677user618677
1,89855 gold badges1717 silver badges2121 bronze badges
7 Answers
On Ubuntu it is advised to use the distributions repository. So installing python-mysqldb should be straight forward:
If you actually want to use pip to install, which is as mentioned before not the suggested path but possible, please have a look at this previously asked question and answer: pip install mysql-python fails with EnvironmentError: mysql_config not found
Here is a very comprehensive guide by the developer: http://mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to-install.html
To get all the prerequisites for python-mysqld to install it using pip (which you will want to do if you are using virtualenv), run this:
Community♦
GlaslosGlaslos
2,20211 gold badge1515 silver badges2828 bronze badges
You have 2 options, as described bellow:
Distribution package like Glaslos suggested:
In this case you can't use virtualenv no-site-packages (default option)but must use:
Use clean virtualenv and build your own python-mysql package.
Install Mysql Ubuntu
First create virtualenv:
Then install build dependencies:
Now you can install python-mysql
NOTE Ubuntu package is python-mysql*db* , python pypi package is python-mysql (without db)
Kris Hollenbeck
13.1k1818 gold badges5454 silver badges9191 bronze badges
Luka MarinkoLuka Marinko
1,63222 gold badges1111 silver badges1414 bronze badges
samayo
10.9k1212 gold badges6161 silver badges9191 bronze badges
MayankMayank
3,69411 gold badge1111 silver badges1515 bronze badges
Reread the error message. It says:
sh: mysql_config: not found
If you are on Ubuntu Natty, gsbabilgsbabil
mysql_config belongs to package libmysqlclient-dev
5,51411 gold badge2020 silver badges2525 bronze badges
this worked for me on python 3
pip install mysqlclient
JouhaynaJouhayna
10.9k1212 gold badges6161 silver badges9191 bronze badges
xiecheng127xiecheng127
Python or Python3 with MySQL, you will need these. These libraries use MySQL's connector for C and Python (you need the C libraries installed as well), which overcome some of the limitations of the mysqldb libraries.
David Peterson HarveyDavid Peterson Harvey
16922 gold badges33 silver badges1414 bronze badges
Not the answer you're looking for? Browse other questions tagged pythonmysql or ask your own question.
Active3 months ago
How can I install the MySQLdb module for Python using pip?
Marian
MarianMarian
9,36644 gold badges2525 silver badges3838 bronze badges
19 Answers
It's easy to do, but hard to remember the correct spelling:
If you need 1.2.x versions (legacy Python only), use
pip install MySQL-python
Note: Some dependencies might have to be in place when running the above command. Some hints on how to install these on various platforms:
Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie)Fedora 24:Mac OS
if that fails, try
Nick T
15.5k55 gold badges6666 silver badges102102 bronze badges
MarianMarian
9,36644 gold badges2525 silver badges3838 bronze badges
Starting from a fresh Ubuntu 14.04.2 system, these two commands were needed:
Just doing the 'pip install' by itself did not work.
From http://codeinthehole.com/writing/how-to-set-up-mysql-for-python-on-ubuntu/
Ray KiddyRay Kiddy
2,23322 gold badges1515 silver badges2929 bronze badges
I had problems installing the 64-bit version of MySQLdb on Windows via Pip (problem compiling sources) [32bit version installed ok]. Managed to install the compiled MySQLdb from the .whl file available from http://www.lfd.uci.edu/~gohlke/pythonlibs/
The .whl file can then be installed via pip as document in https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
For example if you save in
C:/ the you can install via
pip install c:/MySQL_python-1.2.5-cp27-none-win_amd64.whl
Follow-up: if you have a 64bit version of Python installed, then you want to install the 64-bit AMD version of MySQLdb from the link above [i.e. even if you have a Intel processor]. If you instead try and install the 32-bit version, I think you get the unsupported wheel error in comments below.
kyreniakyrenia
2,39422 gold badges3737 silver badges6666 bronze badges
kinsley kajivakinsley kajiva
Mac Install Python Mysql Connector
1,25711 gold badge1313 silver badges1919 bronze badges
First
Then put the code below into
__init__.py (projectname/__init__.py )
My environment is (python3.5, django1.10) and this solution works for me!
Hope this helps!!
NickD
![]()
2,98411 gold badge1313 silver badges2525 bronze badges
放課後放課後
I tried all the option but was not able to get it working on Redhat platform.I did the following to make it work:-
Once the package was installed was able to import module as follows in the interpreter:-
AshwinAshwin
2,07311 gold badge99 silver badges1717 bronze badges
Go to pycharm then go to default setting --> pip (double click) -- pymsqldb..-- > install --after installing use in a program like this
Benoît Latinier
1,69422 gold badges1919 silver badges2828 bronze badges
Java By KiranJava By Kiran
If you are use Raspberry Pi [Raspbian OS]
There are need to be install pip command at first
So that just install Sequently
Héctor Valverde Pareja
1,04711 gold badge1212 silver badges3030 bronze badges
Tanakorn LueangkajonvitTanakorn Lueangkajonvit
You can go to this website to download the package.
hg8
75611 gold badge1111 silver badges2424 bronze badges
bob90937bob90937
If you are unable to install mysqlclient you can also install pymysql:
pip install pymysql
This works same as MySqldb. After that use pymysql all over instead of MySQLdb
quinz
1,02033 gold badges1818 silver badges2626 bronze badges
Aniket BabhulkarAniket Babhulkar
I had the same problem too.Follow these steps if you are on Windows.Go to:1.My Computer2.System Properties3.Advance System Settings4. Under the 'Advanced' tab click the button that says 'Environment Variables'5. Then under System Variables you have to add / change the following variables: PYTHONPATH and Path. Here is a paste of what my variables look like:python path:
path:
See this link for reference
Community♦
d-coderd-coder
5,00033 gold badges1515 silver badges2626 bronze badges
The above answer is great, but there may be some problems when we using pip to install MySQL-python in Windows
for example,It needs some files that are associated with Visual Stdio .One solution is installing VS2008 or 2010……Obviously,it cost too much.
Another way is the answer of @bob90937 . I am here to do something to add.
with http://www.lfd.uci.edu/~gohlke/pythonlibs, u can download many Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language.
![]()
Back to topic,we can choose the MySQL-python(py2) or Mysqlclient(py3) and use pip install to install. it gives us Great convenience!
VastVast
Frank HarbFrank Harb
pip install mysql-connector-python as noted in the documentation:
83211 gold badge88 silver badges1212 bronze badges
on RHEL 7:
sudo yum install yum-utils mariadb-devel python-pip python-devel gcc
sudo /bin/pip2 install MySQL-python
9,96344 gold badges6060 silver badges6262 bronze badges
Frank T
3,65133 gold badges3131 silver badges5757 bronze badges
Marc GottliebMarc Gottlieb
If you have Windows installed on your system then type the following command on cmd :
if the above command does not work try using:
Now,if the above commands do not get the work done, try using:
That's it you are good to go now.
kesari007kesari007
My environment are:
pip install mysqlclient-1.3.13-cp37-cp37m-win_amd64.whl
works for me.
Павел ППавел П
actually, follow @Nick T's answer doesn't work for me, i try
apt-get install python-mysqldb work for me
vickey wuvickey wu
Not the answer you're looking for? Browse other questions tagged pythonmysqlpip or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |