Академический Документы
Профессиональный Документы
Культура Документы
2 on Mac OS X | MangoOrange
`
1/23/12 9:37 PM
MangoOrange
Web Hosting Reviews & Mac WordPress Theme Web Hosting Articles AlreadyHosting.com Best Web Hosting Blog Hosting Business Web Hosting Cheap Hosting Dedicated Web Hosting Domain Name Google Web Hosting Green Web Hosting Personal Notes Random Reliable Hosting Reseller Hosting Web Design Web Host Coupon Codes Web Hosting Web Hosting News Web Hosting Promotions Web Hosting Reviews Web Hosting Tips Website hosting Wordpress Wordpress Hosting Wordpress Themes Paid Advertisement: Fastest Web Hosting After a few hours of searching, I found a few references that somewhat not entirely complete. I did some cross referencing and found two brings me to the entire solutions, which I'm about to show below. Step 0: Before I start, I assumed that you have MySQL and Python installed on the mac. Step 1: Download the latest MySQL for Python adapter from SourceForge. Step 2: Extract your downloaded package by typing $ tar xzvf MySQL-python-1.2.2.tar.gz Step 3: Inside the folder, clean the package by typing $ sudo python setup.py clean Step 4: In the same folder, edit _mysql.c using your favourite text-editor 4a. Remove the following lines (37-39): #ifndef uint #define uint unsigned int #endif 4b. Change the following: uint port = MYSQL_PORT; uint client_flag = 0; to unsigned int port = MYSQL_PORT; unsigned int client_flag = 0; Step 5: Create a symbolic link under lib to point to a sub-directory called mysql. This is where it looks for during compilation. $ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql Step 6: Edit the setup_posix.py and change the following mysql_config.path = "mysql_config" to mysql_config.path = "/usr/local/mysql/bin/mysql_config" Step 7: In the same directory, rebuild your package (ignore the warnings that comes with it) $ sudo python setup.py build Step 8: Install the package and you are done. Mac Web Hosting Web Hosting Resources Bluehost $4.95 Fat Cow Hosting Web Hosting VOIP Reviews Hostmonster $3.95 110mb Blog Google Web Hosting Domain Availability Tool Web Hosting Services Web Hosting Thanks for visiting MangoOrange.com. Our site is know for providing free wordpress templates and other webmaster news. We believe it is imporant that you find the best web hosting provider for your web site. From our experience we know that Hostmonster, Bluehost, and Justhost provide excellent web hosting options. Our free wordpress theme works great with both of these hosts.
Aug 01
i3Theme (3 Column) i2Theme (2 Column) Wordpress Review Theme (premium) Sponsored Ads BlueHost Review
I started working on Python start of the year and I learned a lot while I'm doing my internship in my current company, MooWee Inc. So it's logical for me to try to pick up Django as the web framework. One of the hurdle I met and everyone else met is trying to install MySQL adapter for Python. Being the most popular database used, it is crucial to have it work rather than circumventing around the problem by using alternative database such as SQLite or PostgreSQL.
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 1 of 7
1/23/12 9:37 PM
2. aceplace Says:
September 9th, 2008 at 11:21 pm
dude, you rock! they need to include this info in the install / readme file!
3. Emily Says:
November 11th, 2008 at 5:43 am
Thank you so much! I spent a few hours searching all over google to try to solve this problem with no luck, but this did it! None of the other instructions I found included all the necessary steps.
4. Giedrius Says:
November 28th, 2008 at 6:09 am
Thanks for the instructuctions! After compiling and installing without errors the test line gave an import error. Any suggestions? thanksGiedrius >>> import MySQLdb Traceback (most recent call last): File , line 1, in File MySQLdb/__init__.py, line 19, in import _mysql File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 7, in File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 6, in __bootstrap__ ImportError: dynamic module does not define init function (init_mysql)
5. Giedrius Says:
December 2nd, 2008 at 2:03 am
For those falling in the same traps of MySQLdb: with some googling I discovered that above mistake is likely to be due to Mac archtecture incompatibilities between preinstalled Mac Python (32 bit) and other components (MySQL 64 bit etc). After making sure I have 32 bit versions for everything on my iMac (OS 10.5.5), MySQLdb successfully started after reverting to 1.2.1 version (1.2.2 kept giving error in my previous message). .. Giedrius
6. Kearney Says:
December 9th, 2008 at 8:29 am
Gledrius, I downgraded to 1.2.1. but, I had to do some extra steps. I modified the _mysql.c to remove the defining of the unit and changed everything from to uint to unsigned int. In setup.py I added: /usr/local/mysql/bin/ to the line f = popen(mysql_config %s % what)
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 2 of 7
1/23/12 9:37 PM
Kearney, Many thanks for the help. Ive read elsewhere that people have been downgrading to version 1.2.1. I followed your instructions, and I got the following error: [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. >>> import MySQLdb Traceback (most recent call last): File , line 1, in File MySQLdb/__init__.py, line 19, in import _mysql ImportError: dynamic module does not define init function (init_mysql) would be most grateful if you have any ideas about whats going on. I went through the process of removing the library files and altering the _mysql.c and setup.py files, and Im wondering if theres something else Im missing. Kind regards, -David
9. ds Says:
January 24th, 2009 at 4:01 am
Hi, it seems to have worked! THANK YOU! The one quirk is when I import MySQLdb I get the following error: Warning (from warnings module): File /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/sitepackages/MySQL_python-1.2.2-py2.6-macosx-10.3-i386.egg/MySQLdb/__init__.py, line 34 DeprecationWarning: the sets module is deprecated I imagine its because Im running Python 2.6 and there is a change in store for the sets module that is called but Im a newbie and cant quite figure this out. Any ideas?
I kept getting the following error even after converting to 32-bit mysql: ImportError: dynamic module does not define init function (init_mysql) Then I discovered that the clean option for setup.py does not actually clean out all the old built files so you have to manually delete everything under the build directory if you previously built with a 64-bit mysql library.
Worked. Thanks!
Hi Friend, I got some problem regarding building setup.py file. I am pasting the following error
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 3 of 7
1/23/12 9:37 PM
Thank you, thank you, thank you, thank you. Thank you.
OSX 10.5.6 Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13) >>> import MySQLdb /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5i386.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5i386.egg/_mysql.pyc, but /Users/stephenkennedy-clark/Desktop/MySQL-python-1.2.2 is being added to sys.path import sys, pkg_resources, imp Traceback (most recent call last): File , line 1, in File MySQLdb/__init__.py, line 19, in import _mysql File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 7, in File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 6, in __bootstrap__ ImportError: dynamic module does not define init function (init_mysql)
I got pages and pages of errors when I tried to build. Thanks for trying.
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 4 of 7
1/23/12 9:37 PM
Still getting this error: ImportError: dynamic module does not define init function (init_mysql) Traceback (most recent call last): File /Users/me/Applications/python/test/src/test.py, line 17, in import MySQLdb File build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py, line 19, in File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 7, in File build/bdist.macosx-10.5-i386/egg/_mysql.py, line 6, in __bootstrap__ ImportError: dynamic module does not define init function (init_mysql) Ive tried multiple options to get MySQLdb working on 10.5.6: - http://mysql-python.blogspot.com/2008/03/i-am-not-dead.html - http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/ and Ive tried Mac Python 3.0. I seem to be in a Catch-22 the version 2.3/2.5 Pythons that comes with 10.5 wont work, the 3.0 Python cant find the MySQLdb package at all and presumably will also miss any other (add-on) local packages Ive installed. Is there any other alternative to dumping out the MySQL data into a suitable flat file format and sucking it back into a python dictionary primitive, but probably will work for now though Ill pay a price every time the data in the database changes. Anyone have a MySQLdb fix that works for OS X 10.5.6? I admit Im surprised that python, which has been so robust in having libraries and methods for so many things, hasnt got something as simple as a working Mac OS X MySQL interface. Heck, even Perl has multiple to chose from. Thanks for any assistance
all ok, but the build does not work. Any clue? olea:MySQL-python-1.2.2 jvilla$ sudo python setup.py build running build running build_py creating build creating build/lib.macosx-10.3-i386-2.5 copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.5 creating build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb creating build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i3862.5/MySQLdb/constants running build_ext building _mysql extension creating build/temp.macosx-10.3-i386-2.5 gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 Dversion_info=(1,2,2,final,0) -D__version__=1.2.2 -I/usr/local/mysql/include I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-i386-2.5/_mysql.o -g -Os -arch x86_64 -fno-common D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT DDONT_DECLARE_CXA_PURE_VIRTUAL In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:57, from pymemcompat.h:10, from _mysql.c:29: /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyport.h:761:2:
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 5 of 7
1/23/12 9:37 PM
In what directory (aka folder) should I start this process? The download drops the tar.gz file on my desktop, but that seems an odd place to start an installation. Thank you! Michael
20. no Says:
April 28th, 2009 at 12:13 pm
21. no Says:
April 28th, 2009 at 1:18 pm
Correction, simply doesnt work with MAMP. Instructions work fine with 10.5.6 once I junked MAMP.
OSX Server 10.5 any ideas. I get the following warning. Is that a bad thing or is this a harmless warning. Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type help, copyright, credits or license for more information. >>> import MySQLdb /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/sitepackages/MySQL_python-1.2.2-py2.6-macosx-10.3-fat.egg/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated >>>
http://sourceforge.net/forum/message.php?msg_id=5808948 This link fixed my issue above. Its also good to make sure that if you build your own version of Python that you update all of the SymLinks.
This was a great posting, and ultimately the instructions on this page saved me: http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/ Explanation: I had the same problem (errors) as David Morton, after following Kearnys advice. I tried downgrading to 1.2.2, then 1.2.1 using that advice, and still got: >>> import MySQLdb Traceback (most recent call last): File , line 1, in File MySQLdb/__init__.py, line 19, in import _mysql ImportError: dynamic module does not define init function (init_mysql)
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 6 of 7
1/23/12 9:37 PM
If youre having trouble getting it installed the new version of mysql-python requires some different instructions, also if youre using 64 or 32 bit versions of python or mysql will make a difference. Theres some information here: http://learninglamp.wordpress.com/2010/02/21/mysqldb-python-mysql-and-os-x-amatch-made-in-satans-bum/
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Page 7 of 7