I'm building the django tutorial project, and MySQLdb seems to be working fine (it creates tables, so it must be right?) However, when I try to verify MySQLdb is working by using >>>import MySQLdb, I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/Tom/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/_mysql.so, 2): image not found
This is really odd! Not least because the egg I'm using is 10.5, NOT 10.3 as stated in this error message. Plus, its looking for the egg in /Users/Tom/.python-eggs, and not Library/Python/2.5/site-packages, where the egg is! (The egg is named MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg).
Not I'm not grumbling too much as this was a nightmare to install in the first place and it seems to be working... however its a bit unnerving, so any thoughts?
Thanks :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On the Mac, it's very easy to end up with multiple Python installations in very different locations. And the way this works seems to be different for each OS X release.
The Django Tutorial Project is probably using a different Python than the default system Python. You have MySQLdb installed for the Django Python but not for the Python that came pre-installed with OS X 10.5, which is probably an older version.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, that makes sense - in /Library/python I have a 2.3 folder and a 2.5 folder - the 2.5 is the one django is using I think. Is there a way to sort this out - or any reason to do you think?
Thanks again,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, you don't want to get rid of the original system python, as some parts of OS X use it. And removing the other would break Django, I would guess. So I'm not sure there's really anything to do to "sort it out."
The one thing you might want to do is to make sure you're using the Python 2.5 version when you go in to do your own work. Sorry, I don't recall the specifics of how to do that, but I think it involves changing the "python" alias to point to 2.5 instead of 2.3.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/Tom/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/_mysql.so, 2): image not found
This looks like you are running MySQLdb from the build dir -- rather than the installed version. This can happen if you start up python from a directory near the build dir -- try cd-ing to somewhere no where near, and see what you get.
> it's very easy to end up with multiple Python installations in very
> different locations. And the way this works seems to be different for
> each OS X release.
Not really - the only thing that changes is which version of Python Apples supplies. But yes, it's easy to to have multiple versions, and get confused about which one you are running.
> The one thing you might want to do is to make sure you're using the
> Python 2.5 version when you go in to do your own work.
ah -- but which one? Apple supplied on with 10.5, it lives in /System/Library/.... There is also the python.org build -- it will get installed in /Library/...
> Sorry, I don't recall the specifics of how to do that, but I think it involves
> changing the "python" alias to point to 2.5 instead of 2.3.
I don't know that django is using, but if you poke into it, looking at launch scripts and/or #! lines, you may be able to figure it out. At the command line, you can type "python" and see what version is running, type "which python" to see which python the shell finds by default. yu can also type
>> import sys
>> sys._file__
to see exactly where the running resides.
no -- you don't want to do that. All you want to change is what is on your shell PATH. type:
echo $PATH
to see what's there. You can change it by editing your .bash_profile (or .profile ) file.
For more help, try the pythonmac list
-Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Running OS 10.5.6
I'm building the django tutorial project, and MySQLdb seems to be working fine (it creates tables, so it must be right?) However, when I try to verify MySQLdb is working by using >>>import MySQLdb, I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/Tom/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/_mysql.so, 2): image not found
This is really odd! Not least because the egg I'm using is 10.5, NOT 10.3 as stated in this error message. Plus, its looking for the egg in /Users/Tom/.python-eggs, and not Library/Python/2.5/site-packages, where the egg is! (The egg is named MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg).
Not I'm not grumbling too much as this was a nightmare to install in the first place and it seems to be working... however its a bit unnerving, so any thoughts?
Thanks :)
Ah, ok, things are becoming clearer!
'which python' returned: /usr/local/bin/python
'python' returned: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
So, I changed my $PATH. Now returns:
'which python' : /usr/bin/python
'python': Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) / [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
and 'import MySQLdb' now works! So its the slightly older version of Python that has the MySQLdb installed properly.
Thanks for all the help.
On the Mac, it's very easy to end up with multiple Python installations in very different locations. And the way this works seems to be different for each OS X release.
The Django Tutorial Project is probably using a different Python than the default system Python. You have MySQLdb installed for the Django Python but not for the Python that came pre-installed with OS X 10.5, which is probably an older version.
Ah, that makes sense - in /Library/python I have a 2.3 folder and a 2.5 folder - the 2.5 is the one django is using I think. Is there a way to sort this out - or any reason to do you think?
Thanks again,
Well, you don't want to get rid of the original system python, as some parts of OS X use it. And removing the other would break Django, I would guess. So I'm not sure there's really anything to do to "sort it out."
The one thing you might want to do is to make sure you're using the Python 2.5 version when you go in to do your own work. Sorry, I don't recall the specifics of how to do that, but I think it involves changing the "python" alias to point to 2.5 instead of 2.3.
Ok, that makes sense... I'll have a snoop around see if I can figure out how to do that.
Thanks again for your time.
Regards,
From the look of this traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/Tom/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/_mysql.so, 2): image not found
This looks like you are running MySQLdb from the build dir -- rather than the installed version. This can happen if you start up python from a directory near the build dir -- try cd-ing to somewhere no where near, and see what you get.
> it's very easy to end up with multiple Python installations in very
> different locations. And the way this works seems to be different for
> each OS X release.
Not really - the only thing that changes is which version of Python Apples supplies. But yes, it's easy to to have multiple versions, and get confused about which one you are running.
> The one thing you might want to do is to make sure you're using the
> Python 2.5 version when you go in to do your own work.
ah -- but which one? Apple supplied on with 10.5, it lives in /System/Library/.... There is also the python.org build -- it will get installed in /Library/...
> Sorry, I don't recall the specifics of how to do that, but I think it involves
> changing the "python" alias to point to 2.5 instead of 2.3.
I don't know that django is using, but if you poke into it, looking at launch scripts and/or #! lines, you may be able to figure it out. At the command line, you can type "python" and see what version is running, type "which python" to see which python the shell finds by default. yu can also type
>> import sys
>> sys._file__
to see exactly where the running resides.
no -- you don't want to do that. All you want to change is what is on your shell PATH. type:
echo $PATH
to see what's there. You can change it by editing your .bash_profile (or .profile ) file.
For more help, try the pythonmac list
-Chris