Django users,
What's the latest on the easiest way to access MySQL from Django
on Mac OS X 10.6.8 (Snow Leopard)?
I've Googled lots of info, but some may be outdated. Seems to be
more complicated than it should be, especially since everything else
to do with Django has been so easy.
Here's what I've done and learned:
- Followed MYSQLdb link in Django docs:
https://docs.djangoproject.com/en/1.4/topics/install/#database-installation
to:
http://sourceforge.net/projects/mysql-python/
and downloaded:
MySQL-python-1.2.3.tar.gz
- More info at: http://mysql-python.sourceforge.net/
- Confirmed it is not already installed:
% python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: No module named _mysql
>>>
% gunzip MySQL-python-1.2.3.tar.gz
% tar -xvf MySQL-python-1.2.3.tar
% less README
- Lots of caveats. Has to be built and installed. Looks
ugly.
- Says it requires setuptools Python module.
- Confirmed setuptools is not already installed, by trying
the import
statement that setup.py is going to do:
% python
>>> from setuptools import setup, Extension
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>>
% python setup.py build
- Got error, as expected:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
Exit 1
% sudo python setup.py install
- No. Didn't try. Not yet built.
So now I need setuptools first. Am I starting down a long
dependency
chain of installs, or will this be easy?
I have a Linux server, where it appears that I could use yum to do
a painless install:
% yum list all | grep -i mysql | grep -i py
MySQL-python.x86_64 1.2.3-0.3.c1.1.8.amzn1
amzn-main
Perhaps there's an easier way for Mac OS X also? Did some more
Googling and found:
http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x
which is a longish manual set of instructions by an author who
wishes
there were a better way, but another reply says to just use MacPorts
to
install it.
Any advice? Thanks!