0

mySQL seems to be up and running just fine. But when I try to import MySQLdb into python I get a ImportError: ... Expected in: flat namespace. I think it has to do with having two different versions for python (well two different directories, same version)

OS: Mac 10.6.8

$ ls /Library/Frameworks/Python.framework/Versions/
7.2 Current

$ which python
/Library/Frameworks/Python.framework/Versions/Current/bin/python

$ echo $PATH
/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

$ easy_install MySQL-python
...
...
Using /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg
...

$ mysql.server start
Starting MySQL
.. SUCCESS!

$ python manage.py runserver
...
...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so

$ python
Enthought Python Distribution (EPD) free version -- www.enthought.com
Version: 7.2-2 (32-bit)

>>> import MySQLdb
...
...
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-i386.egg/_mysql.so

So in addition to being new to django and python I'm also new to using the terminal, and I'm not exactly sure what I'm looking at.

But I can tell the obvious:

  • I have two versions, 7.2 and current.
  • If I call python it will call the 'Current' version. That makes sense, it's in $PATH.
  • However, a version 2.7 (not 7.2) is also in PATH which I had deleted when I installed the EDP package. ...I don't fully understand what PATH is or does so I didn't want to start changing things
  • MySQL-python is installed in version 7.2
  • Can't run the server because a necessary file isn't in flat namespace and it's at the place it was installed too

Is there some way to untangle these paths (if that's the problem)

thank you in advance

Ben
  • 6,986
  • 6
  • 44
  • 71

1 Answers1

0

Well... I don't think it had anything the do with the "Current" and "7.2" versions of python.

It seems to have fixed itself after doing

pip uninstall MySQL-python
brew uninstall mysql
brew install mysql --universal
pip install MySQL-python

I'm not sure if the --universal made the diference or using pip install as opposed to easy_install

Ben
  • 6,986
  • 6
  • 44
  • 71
  • Tried this but got "-- Configuring incomplete, errors occurred!" when trying to install the --universal version, but plain mysql no problem. – PhoebeB Jul 29 '13 at 14:24