8 Replies - 1410 Views - Last Post: 22 February 2011 - 01:27 PM Rate Topic: -----

#1 Guest_Patrick*


Reputation:

Python/MySQL/Django Help

Posted 22 February 2011 - 12:14 PM

I've seen two dozen posts concerning this issue, but I'm so NOOB I'm not sure how to modify everything correctly.

I'm attempting to finish the installation, but when I go to Python and "import MySQLdb" I end up getting:

ImportError: dlopen(/Users/pccampbell/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg-tmp/_mysql.so, 2):
Library not loaded: libmysqlclient.16.dylib
Referenced from: /Users/pccampbell/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg-tmp/_mysql.so


I then run this command which everyone says works (and it does, but only temporarily!):

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/


SO, I'm trying to execute the following to permanently change the path (as found on another help site):

sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib lib/python2.7/site-packages/_mysql.so


BUT, I end up getting this error:

install_name_tool: can't open file: lib/python2.7/site-packages/_mysql.so (No such file or directory)


I found the _mysql.so file at, but even when I use this path it doesn't work:

/Users/pccampbell/MySQL-python-1.2.3/build/lib.macosx-10.5-fat3-2.7



THE BOTTOM LINE: is there a way to permanently modify the DYLD_LIBRARY_PATH, so I don't have to run the export command every time. If so, then could you please, please, please provide the specific syntax, because I've been guessing and checking for a long time. :(

Any help GREATLY appreciated.

Patrick

Is This A Good Question/Topic? 0

Replies To: Python/MySQL/Django Help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6033
  • View blog
  • Posts: 23,414
  • Joined: 23-August 08

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:19 PM

Assuming you're using bash, you could add it to ~/.bash_profile.
Was This Post Helpful? 1
  • +
  • -

#3 patticus73  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-February 11

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:20 PM

View PostJackOfAllTrades, on 22 February 2011 - 12:19 PM, said:

Assuming you're using bash, you could add it to ~/.bash_profile.


Not to show how "green" I am, but how would I do that?

Patrick
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6033
  • View blog
  • Posts: 23,414
  • Joined: 23-August 08

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:26 PM

There's probably some other way to do what you're attempting, but I'm honestly not all that familiar with using Python along with MySQL and/or Django.

Edit the .bash_profile file in your home directory to include the line
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/my/path/to/add


EDIT: Added export to ensure variable gets, well, exported.

This post has been edited by JackOfAllTrades: 22 February 2011 - 12:36 PM

Was This Post Helpful? 0
  • +
  • -

#5 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:27 PM

Yes, you will either need to add it to configuration file for your shell (.bash_profile, .bashrc, .profile, etc...Check your shell's documentation), or you will need to fix your call to install_name_tool.

What you will need to do is locate your Python installation's site-packages directory:
$ locate site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages



And fit that into your call to install_name_tool:
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so



Make sure to use the directory from your results, not mine!
Was This Post Helpful? 0
  • +
  • -

#6 patticus73  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-February 11

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:45 PM

This is really helpful. I'm really sorry for more questions, but:

This is the location of _mysql.so:

 /Users/pccampbell/MySQL-python-1.2.3/build/lib.macosx-10.5-fat3-2.7 


which is apparently wrong.

When I run: locate site-locations I get an extremely long list where this exists, but _mysql.so doesn't:

 pccampbell-macbookpro:~ pccampbell$ sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so
install_name_tool: can't open file: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so (No such file or directory)


Do I need to move the _mysql.so file?
Was This Post Helpful? 0
  • +
  • -

#7 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 12:49 PM

Sounds like you don't have the Python module MySQLdb installed.
Was This Post Helpful? 0
  • +
  • -

#8 patticus73  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-February 11

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 01:16 PM

View PostMotoma, on 22 February 2011 - 12:49 PM, said:

Sounds like you don't have the Python module MySQLdb installed.



I know it's downloaded. I just don't think it's in the right place. I am able to temporarily access MySQLdb if I use the execute command above, but I'd like to make this permanent through what you've been proposing.

My biggest problem is when I type in locate site-packages there's a million things that pop up. I just think it's because _mysql.so is located here:

 /Users/pccampbell/MySQL-python-1.2.3/build/lib.macosx-10.5-fat3-2.7 


Do I need to move it?

Thanks so much!
Was This Post Helpful? 0
  • +
  • -

#9 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: Python/MySQL/Django Help

Posted 22 February 2011 - 01:27 PM

I'm sorry, you're right.

Honestly, if the export works, I would use that over install_name_tool.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1