补记一下后续:
command line tool装上之后,用easy_install安装mysql-python:
$ sudo easy_install mysql-python
Password:
Searching for mysql-python
Reading
http://pypi.python.org/simple/mysql-python/Reading
http://sourceforge.net/projects/mysql-python/Reading
http://sourceforge.net/projects/mysql-pythonBest match: MySQL-python 1.2.3
Downloading
http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gzProcessing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/
setup.py -q bdist_egg --dist-dir /tmp/easy_install-XKbf0S/MySQL-python-1.2.3/egg-dist-tmp-Y1AssU
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from _mysql.c:36:
/usr/local/mysql-5.5.25-osx10.6-x86_64/include/my_config.h:329:11: warning: 'SIZEOF_SIZE_T' macro
redefined
#define SIZEOF_SIZE_T SIZEOF_LONG
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:43:17: note:
previous definition is here
# define SIZEOF_SIZE_T 8
^
In file included from _mysql.c:36:
/usr/local/mysql-5.5.25-osx10.6-x86_64/include/my_config.h:422:9: warning: 'HAVE_WCSCOLL' macro redefined
#define HAVE_WCSCOLL
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:891:9: note:
previous definition is here
#define HAVE_WCSCOLL 1
^
_mysql.c:253:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int'
[-Wshorten-64-to-32]
cmd_argc = PySequence_Size(cmd_args);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:278:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int'
[-Wshorten-64-to-32]
groupc = PySequence_Size(groups);
~ ^~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:405:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int'
[-Wshorten-64-to-32]
int j, n2=PySequence_Size(fun);
~~ ^~~~~~~~~~~~~~~~~~~~
_mysql.c:986:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int'
[-Wshorten-64-to-32]
len = mysql_real_escape_string(&(self->connection), out, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:988:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int'
[-Wshorten-64-to-32]
len = mysql_escape_string(out, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1016:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int'
[-Wshorten-64-to-32]
size = PyString_GET_SIZE(s);
~ ^~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note:
expanded from macro 'PyString_GET_SIZE'
#define PyString_GET_SIZE(op) Py_SIZE(op)
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note:
expanded from macro 'Py_SIZE'
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
_mysql.c:1025:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int'
[-Wshorten-64-to-32]
len = mysql_real_escape_string(&(self->connection), out+1, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1027:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int'
[-Wshorten-64-to-32]
len = mysql_escape_string(out+1, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1111:11: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int'
[-Wshorten-64-to-32]
if ((n = PyObject_Length(o)) == -1) goto error;
~ ^~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:434:25: note:
expanded from macro 'PyObject_Length'
#define PyObject_Length PyObject_Size
^
_mysql.c:1298:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to
'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1300:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to
'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1336:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to
'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1338:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to
'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1421:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (how < 0 || how >= sizeof(row_converters)) {
~~~ ^ ~
16 warnings generated.
zip_safe flag not set; analyzing archive contents...
Adding MySQL-python 1.2.3 to easy-install.pth file
Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg
Processing dependencies for mysql-python
Finished processing dependencies for mysql-python
虽然有一些奇怪的东西出现,但好歹装上了。
接着去web.py下运行project试试能不能启动:
$ python
application.pyTraceback (most recent call last):
File "
application.py", line 13, in <module>
import config
File "/Users/hanjiyun/Project/sputnik/
config.py", line 10, in <module>
db = web.database(dbn='mysql', db='mlss', user='sputnik', passwd='paloalto-3859675')
File "/Library/Python/2.7/site-packages/
web.py-0.37-py2.7.egg/web/
db.py", line 1143, in database
return _databases[dbn](**params)
File "/Library/Python/2.7/site-packages/
web.py-0.37-py2.7.egg/web/
db.py", line 975, in __init__
import MySQLdb as db
File "build/bdist.macosx-10.8-intel/egg/MySQLdb/
__init__.py", line 19, in <module>
File "build/bdist.macosx-10.8-intel/egg/
_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.8-intel/egg/
_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/hanjiyun/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/
_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/hanjiyun/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/
_mysql.so Reason: image not found
悲剧,后来在
http://yan-yan.info/2011/install-mysql-5.5-on-mac-os-10.7-with-python-support.html 找到办法:
在/etc的profile文件中加入一行
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"
然后重启电脑。
再次运行项目,发现无法与Mysql连接,我这才想起来mysql还没启动,我的mysql版本是mysql-5.5.25-osx10.6-x86_64,需要通过“系统偏好设置” 中的MySQL面板来启动。
http://ww1.sinaimg.cn/large/61b8bbf4gw1dvarzkytqgj.jpg但是启动的时候发现报错:
Warning: The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user
在stackoverflow找到解决办法:
http://stackoverflow.com/questions/4762543/mysql-what-user-should-own-usr-local-mysql-on-mac按照帖子中说的,运行命令:
sudo chown -R _mysql:wheel /usr/local/mysql/data
Mysql顺利启动。
再次运行项目:
$ python
application.pyhttp://0.0.0.0:8080/
终于搞定了。
绳命在于折腾。