![mac python install mysqldb mac python install mysqldb](http://www.brambraakman.com/images/uploads/mac_os_x_snow_leopard.jpg)
Edit away, or provide your own, better answer. out of build directory and the error should disappear.Īs I wrote at the top, I’d love to see this answer generalised, as there are numerous other specific experiences of this horrible problem out there. This is pretty easy to Google, but to save you the trouble you will end up here (or maybe not… not a particularly future-proof URL) and figure out that you need to cd. Library/Python/2.5/site-packages/MySQL_python-1.2./_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.5/site-packages/MySQL_python-1.2./_mysql.pyc, but XXXX/MySQL-python-1.2.3c1 is being added to sys.path One final hiccup though is that if you start Python from the build directory you will get this error:
![mac python install mysqldb mac python install mysqldb](https://a.fsdn.com/con/app/proj/mysql-python/screenshots/2013-06-28%2014.15.58.jpg)
You should then be able to import MySQLdb without any errors. If upon trying to import you receive an error complaining that Library not loaded: libmysqlclient.18.dylib ending with: Reason: image not found you need to create one additional symlink which is: sudo ln -s / usr/ local/ mysql/ lib/ libmysqlclient.18. In the same directory, rebuild your package (ignore the warnings that comes with it) sudo python setup. Mysql_config.path = “/usr/local/mysql/bin/mysql_config” sudo ln -s /usr/ local/mysql/lib /usr/ local/mysql/lib/mysqlĮdit the setup_posix.py and change the following This is where it looks for during compilation. MySQLdb community seem to have fixed this bug now.Ĭreate a symbolic link under lib to point to a sub-directory called mysql. Originally required editing _mysql.c, but is now NO LONGER NECESSARY. Remove the egg under Users/$USER/.python-eggs Remove everything under your MySQL-python-1.2.2/build/* directory - don’t trust the “python setup.py clean” to do it for you py cleanĬOUPLE OF EXTRA STEPS, (from this comment) Inside the folder, clean the package: sudo python setup. I’ve reproduced it with a couple of edits belowīefore I start, I assume that you have MySQL, Python, and GCC installed on the mac.ĭownload the latest MySQL for Python adapter from SourceForge.Įxtract your downloaded package: tar xzvf MySQL-python-1.2.2. This seemed the most popular to me, and provided the working solution.
![mac python install mysqldb mac python install mysqldb](https://cdn.activestate.com/wp-content/uploads/2009/05/how-install-mysql-python-mac-osx-blog-hero.jpg)
#Mac python install mysqldb how to#
There are numerous step-by-steps on how to build and install the MySQLdb libraries.
#Mac python install mysqldb 64 Bit#
Bad move… remove the 64 bit version if you have installed it (instructions on this fiddly task are available on SO here), then download and install the 32 bit version (package here) Note: Comments in next paragraph applied to Snow Leopard, but not to Lion, which appears to require 64-bit MySQLįirst off, the author (still?) of MySQLdb says here that one of the most pernicious problems is that OS X comes installed with a 32 bit version of Python, but most average joes (myself included) probably jump to install the 64 bit version of MySQL. Would love to see it edited or generalised if you have better experience of the issue… apply a bit of that SO magic. Here is the tale of my rambling experience with this problem. Installing mysqlclient will install mysqlclient, mysql-connector, and llvmdev (at least, it installed these 3 libraries on my machine). The following SO question was a helpful clue: Python 3 ImportError: No module named ‘ConfigParser’. You can simply use conda install mysqlclient to install the libraries required to use MySQLdb as it currently exists.