2012-11-23 99 views
3

我花了整整两天的时间试图让python-mysql去年在Lion的干净安装上工作,并最终放弃了绝望。升级到山狮后,我想我会再试一次,但没有成功。这可能是因为我对狮子的所有尝试都搞砸了我的设置,我唯一的希望就是彻底安装,但为了万一任何人都可以救我,这里就是症状。无法在Lion/Mountain Lion上安装python-mysql

首先我删除了三个版本仍然存在:

/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-i386.egg-tmp 
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-i386.egg-tmp/_mysql.so 
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp 
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so 
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-x86_64.egg-tmp 
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-x86_64.egg-tmp/_mysql.so 

然后重新安装。所有这些问题似乎去确定,虽然有警告,似乎是64位版本:

Phoebe-Brights-iMac:.python-eggs phoebebr$ sudo pip install mysql-python 
    dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid 
    Password: 
    Downloading/unpacking mysql-python 
     Downloading MySQL-python-1.2.4c1.zip (113kB): 113kB downloaded 
     Running setup.py egg_info for package mysql-python 
     Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz 
     Extracting in /tmp/tmp7fFOxU 
     Now working in /tmp/tmp7fFOxU/distribute-0.6.28 
     Building a Distribute egg in /private/tmp/pip-build/mysql-python 
     /private/tmp/pip-build/mysql-python/distribute-0.6.28-py2.7.egg 

    Installing collected packages: mysql-python 
     Running setup.py install for mysql-python 
     building '_mysql' extension 
     clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,4,'rc',5) -D__version__=1.2.4c1 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.8-intel-2.7/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch x86_64 
     clang: warning: argument unused during compilation: '-mno-fused-madd' 
     In file included from _mysql.c:44: 
     /usr/local/mysql/include/my_config.h:330: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:44: 
     /usr/local/mysql/include/my_config.h:423: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:287: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:317:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] 
         groupc = PySequence_Size(groups); 
           ~ ^~~~~~~~~~~~~~~~~~~~~~~ 
     _mysql.c:470: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:1105: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:1107:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] 
         len = mysql_escape_string(out, in, size); 
          ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     _mysql.c:1146: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:1156: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:1158: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:1252: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:1444:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32] 
           len = strlen(buf); 
            ~ ^~~~~~~~~~~ 
     _mysql.c:1446:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32] 
           len = strlen(buf); 
            ~ ^~~~~~~~~~~ 
     _mysql.c:1482:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32] 
             len = strlen(buf); 
              ~ ^~~~~~~~~~~ 
     _mysql.c:1484:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32] 
             len = strlen(buf); 
              ~ ^~~~~~~~~~~ 
     _mysql.c:1567:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] 
       if (how < 0 || how >= sizeof(row_converters)) { 
        ~~~^~ 
     16 warnings generated. 
     clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lpthread -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64 

    Successfully installed mysql-python 
    Cleaning up… 

但它仍然不会进口:

Phoebe-Brights-iMac:.python-eggs phoebebr$ python 
    Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
    [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin 
    Type "help", "copyright", "credits" or "license" for more information. 

    >>> import MySQLdb 
    Traceback (most recent call last): 
     File "<stdin>", line 1, in <module> 
     File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in <module> 
     import _mysql 
    ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib 
     Referenced from: /Library/Python/2.7/site-packages/_mysql.so 
     Reason: image not found 

然而它试图加载的文件那里!

Phoebe-Brights-iMac:/ phoebebr$ cd /Library/Python/2.7/site-packages 
    Phoebe-Brights-iMac:site-packages phoebebr$ ls 
    total 792 
    drwxr-xr-x 4 root wheel  136 25 Oct 09:31 Django-1.4.2-py2.7.egg 
    drwxr-xr-x 2 root wheel  238 23 Nov 11:16 MySQL_python-1.2.4c1-py2.7.egg-info 
    drwxr-xr-x 3 root wheel  510 23 Nov 11:16 MySQLdb 
    -rw-r--r-- 1 root wheel  119 11 Oct 23:59 README 
    -rwxr-xr-x 1 root wheel 67240 23 Nov 11:16 _mysql.so 
    -rw-r--r-- 1 root wheel 2352 23 Nov 11:16 _mysql_exceptions.py 
    -rw-r--r-- 1 root wheel 4243 23 Nov 11:16 _mysql_exceptions.pyc 
    -rw-r--r-- 1 root wheel  306 23 Nov 10:37 easy-install.pth 
    drwxr-xr-x 4 root wheel  136 23 Nov 10:37 pip-1.2.1-py2.7.egg 
    -rw-r--r-- 1 root wheel 295372 22 Oct 20:21 pymongo-2.3-py2.7-macosx-10.8-intel.egg 
    -rw-r--r-- 1 root wheel 17994 22 Oct 20:22 sleepy.mongoose-0.1-py2.7.egg 

回答

13

在过去,我一直在全新安装中遇到libmysqlclient.18.dylib错误。

这通常对我来说是诀窍。

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib 

我只是不得不做一个干净的安装山狮,现在有这个包的新问题。 v1.2.4是非常新的。您可以尝试pip安装MySQL-python == 1.2.3,以便安全,因为1.2.4仍然是RC1我认为。

编辑︰

我是一个tard和意外安装32位MySQL。 1.2.4c1确实有效。正如我会建议使用export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/而不是做符号链接。

+0

你是一颗全明星。我做了这两件事情,并开始工作。 Hurraghhhh – PhoebeB

+0

Huzzah!这个lib18的东西和mysql_config的东西每次都让我感觉到。 – yellottyellott

+0

哟我也安装了32位,很高兴你把它放在你的答案中。 – crunkchitis

相关问题