Chris,

Good info.  Thanks!  I'm hearing lots of good things about Homebrew.
If I go to a package manager, I may try it instead of MacPorts.  For now,
I've succeeded with just installing setuptools and MySQLdb, as described
below, and not re-installing MySQL or Python.

I installed MacPorts, but decided not to use it after doing a dry-run
and seeing that it was planning to re-install a bunch of stuff that it
doesn't know I already have installed and configured:  MySQL,
Python, etc.  Seems like MacPorts is too intrusive if you don't use
it from day one for all Mac installs.  Homebrew would have the
same problem, I guess, as do yum and apt-get on Linux.  It's hard
to start using any of them after a couple years of configuring the
system manually because none of the packages you already
installed are recorded in their records.  I may start using Homebrew
the next time I configure a Mac from scratch, just as I now do all
of my Linux boxes via yum.

For now, I did a manual install of Python setuptools, and then a
manual install of the MySQLdb driver for Python.  Everything's
working fine.  Turned out to be as easy as:
  - Download setuptools-0.6c11-py2.7.egg from
http://pypi.python.org/pypi/setuptools/
  % sh setuptools-0.6c11-py2.7.egg
  - Download MySQL-python-1.2.3.tar.gz from
http://sourceforge.net/projects/mysql-python/
  % gunzip MySQL-python-1.2.3.tar.gz
  % tar -xvf MySQL-python-1.2.3.tar
  % cd MySQL-python-1.2.3
  % python setup.py build
  % sudo python setup.py install

--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------

On 9/23/12 11:03 PM, Chris Streeter wrote:
When I'm setting up a new Mac OS system, the process I go through to install Python and MySQL.

First, I install Python using this guide: http://docs.python-guide.org/en/latest/starting/install/osx/ The guide also installs Homebrew, which works great for me so far and is easily removable.

After Python and Homebrew is installed, then you can install mysql with:

brew install mysql

This will get us the proper headers we need to install MySQLdb with pip. After MySQL is installed, you can install MySQLdb into a virtualenv or system-wide with a simple command:

pip install MySQLdb

Hope that helps,

- Chris

On Sun, Sep 23, 2012 at 6:54 PM, Andrew Macgregor <and...@ccg.murdoch.edu.au <mailto:and...@ccg.murdoch.edu.au>> wrote:

    Hi Fred,

    I've also found HomeBrew to be useful. Here's a good setup guide:

    
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/

    Cheers, Andrew.


    On Monday, September 24, 2012 2:02:37 AM UTC+8, Fred Stluka wrote:

        Resolved this on my own.  Here's what I did:

        - Downloaded and installed MacPorts, but decided not to use it
           because I have too much software already installed that
           MacPorts doesn't know about and wants to reinstall (MySQL,
           Python, OpenSSL, etc.)

        - Downloaded and installed Python setuptools and resumed the
           MySQLdb setup that I'd already begun (see my previous post
           appended below).  It turned out to be easy:
           - Download setuptools-0.6c11-py2.7.egg from
        http://pypi.python.org/pypi/setuptools/
           % sh setuptools-0.6c11-py2.7.egg
           % cd MySQL-python-1.2.3
           % python setup.py build
           % sudo python setup.py install

        Success!  Now I can access MySQL from my Python/Django apps.

        BTW, I also downloaded and installed PyCharm.  Nice Python IDE!

        --Fred
        ------------------------------------------------------------------------
        Fred Stluka -- mailt...@bristle.com --
        http://bristle.com/~fred/ <http://bristle.com/%7Efred/>
        Bristle Software, Inc -- http://bristle.com -- Glad to be of
        service!
        Open Source: Without walls and fences, we need no Windows or
        Gates.
        ------------------------------------------------------------------------

        On 9/22/12 5:28 PM, Fred Stluka wrote:
        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!

        --Fred
        ------------------------------------------------------------------------
        Fred Stluka -- mailt...@bristle.com --
        http://bristle.com/~fred/ <http://bristle.com/%7Efred/>
        Bristle Software, Inc -- http://bristle.com -- Glad to be of
        service!
        Open Source: Without walls and fences, we need no Windows or
        Gates.
        ------------------------------------------------------------------------
-- You received this message because you are subscribed to the
        Google Groups "Django users" group.
        To post to this group, send email to django...@googlegroups.com.
        To unsubscribe from this group, send email to
        django-users...@googlegroups.com.

        For more options, visit this group at
        http://groups.google.com/group/django-users?hl=en.

-- You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/django-users/-/5khu9OJAr1sJ.

    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    To unsubscribe from this group, send email to
    django-users+unsubscr...@googlegroups.com
    <mailto:django-users%2bunsubscr...@googlegroups.com>.
    For more options, visit this group at
    http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to