且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mac OS X上的python和mysql

更新时间:2023-01-13 12:05:56

我刚刚将其安装在系统上,这些是我为使其正常运行而执行的步骤:

I've just installed this on my system and these are the steps I did to make it working:

  1. 下载Mysql-python: http://sourceforge.net/projects/mysql -python/files/mysql-python/1.2.2/(我使用的是1.2.2版本)
  2. 解压缩,去那里并通过删除37-19行(ifdefine)来编辑_mysql.c文件
  3. 在site.cfg中设置mysql_config =/usr/local/mysql/bin/mysql_config
  4. sudo python setup.py构建(我运行了两次,而第一个运行时却吐出了一些奇怪的东西,第二次却没有出现错误……我读到了这,这是很奇怪的东西)
  5. sudo python setup.py安装
  6. sudo ln -s/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib
  7. sudo ln -s/usr/local/mysql/lib//usr/local/mysql/lib/mysql
  1. Download Mysql-python: http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/ (I've used 1.2.2 version)
  2. Extract, go there and edit _mysql.c file by removing 37-19 lines (ifdefine)
  3. In site.cfg set mysql_config = /usr/local/mysql/bin/mysql_config
  4. sudo python setup.py build (this one I ran two times, while the first one spitted something weird, second time went without errors... I read about this and this is weird stuff)
  5. sudo python setup.py install
  6. sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
  7. sudo ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql

最后,您只需尝试在python中导入MySQLdb.希望对您也有用.

And finally you just try import MySQLdb in python. Hope that worked also for you.

伊格纳斯