Mac Install Mysql Python

Posted on by

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. I am using OSX 10.8 and PyCharm to work on a Python development project. I have installed MySQL-python for the mac using the instructions on the website. Oct 31, 2008  How to install MySQL-python on Mac OS X Step 1: Brace yourself, this proccess is really really annoying. Step 2: Download MySQL for Mac (Skip. Nov 16, 2012  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.

Active3 months ago

How can I install the MySQLdb module for Python using pip?

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.

Marian
MarianMarian
9,3664 gold badges25 silver badges38 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.5k5 gold badges66 silver badges102 bronze badges
MarianMarian
9,3664 gold badges25 silver badges38 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,2332 gold badges15 silver badges29 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,3942 gold badges37 silver badges66 bronze badges
kinsley kajivakinsley kajiva
1,2571 gold badge13 silver badges19 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!

An Introduction To Language 7th Edition.pdf - Free download Ebook, Handbook, Textbook, User Guide PDF files on the internet quickly and easily. Habib Fauzie. Loading Preview. Download pdf × Close Log In. Log In with Facebook Log In with Google. Email: Password: Remember me on this computer. Download pdf × Close Log In. An Introduction To Language Seventh Edition.pdf - Free download Ebook, Handbook, Textbook, User Guide PDF files on the internet quickly and easily. An introduction to language 7th edition pdf.

Hope this helps!!

NickD
2,9841 gold badge13 silver badges25 bronze badges
放課後放課後
Mac running setup.py install for mysql-python .. error

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,0731 gold badge9 silver badges17 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,6942 gold badges19 silver badges28 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,0471 gold badge12 silver badges30 bronze badges
Tanakorn LueangkajonvitTanakorn Lueangkajonvit

You can go to this website to download the package.

hg8
7561 gold badge11 silver badges24 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,0203 gold badges18 silver badges26 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,0003 gold badges15 silver badges26 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-pythonas noted in the documentation:

Matthew ParkMatthew Park
8321 gold badge8 silver badges12 bronze badges

on RHEL 7:

sudo yum install yum-utils mariadb-devel python-pip python-devel gcc

sudo /bin/pip2 install MySQL-python

wired00wired00
9,9634 gold badges60 silver badges62 bronze badges
Frank T
3,6513 gold badges31 silver badges57 bronze badges
Marc GottliebMarc Gottlieb

If you have Windows installed on your system then type the following command on cmd :

Mysql

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:

  • Windows 10 Pro,
  • Python 3.7 (python-3.7.1-amd64.exe),
  • MySQL 8.0 (mysql-installer-web-community-8.0.13.0.msi)

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

Install Mysql Module Python Mac

Not the answer you're looking for? Browse other questions tagged pythonmysqlpip or ask your own question.