开发者

Mac OS X: Trouble with Local Django + PyDev install working with remote MySQL

I've got PyDev installed in Eclipse. I'm trying to play with Django. I'm got a remote MySQL database set up. I would really like to not install MySQL on my MacBook.

Trying to set up the MySQL plugin for python, I get

(djangotest)jeebus:MySQL-python-1.2.3 b开发者_开发技巧lah$ python setup.py clean
sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

The error makes sense since I don't have any of MySQL or related tools set up.

Are there an Snow Leopard MySQL libraries I can use to satisfy the need for mysql_config without actually installing MySQL?


In a word, no. You need the client side libraries of MySQL but you don't need the server components. Most package managers provide each as separate packages.

MySQL-python, AKA MySQLdb, is not a client module per se. It is a wrapper or interface between Python programs and the standard MySQL client libraries. MySQLdb conforms to the Python standard DB API. There are other conforming adapters implemented for other database managers. Using the common API makes it much easier to write database-independent code in Python; the adapters handle (much of) the messy differences among the various database client libraries. Thus, you do need to install MySQL client libraries; there are several ways to do this: the easiest options are probably downloading prebuilt libraries from mysql.com or you can use a package manager, like MacPorts, to install them and other dependencies.

For OS X 10.6, because of the potential gotchas in getting all of the needed pieces installed in a compatible manner, I highly recommend using a total solution from MacPorts to get Python MySQL support. See the answer here for more details. MacPorts even provides a Django port.


Why not use macports instead. It also has a gui called porticus.


pip install mysql-python

... or use easy_install if you don't have pip.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜