gpt4 book ai didi

python - 在 Mac OS Lion 上安装 oursql 成功,但在 python 中导入失败。 **为什么?**

转载 作者:太空狗 更新时间:2023-10-29 21:06:12 24 4
gpt4 key购买 nike

我按照安装说明在 Mac OS X 上安装 oursql。因为

sudo pip install oursql

告诉我,它找不到 mysql_config 我(使用 locate mysql_config 找到它并)告诉它在哪里可以找到它

sudo MYSQL_CONFIG=/usr/local/mysql-5.5.14-osx10.6-x86_64/bin/mysql_config pip install oursql

出于可读性原因,我在底部添加了终端输出。之后我在终端中启动了 python(在 Mac OS Lion 上它现在是 python 2.7,...)并做了

>>> import oursql

但是 python 一直告诉我:

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

我错过了什么?有什么建议吗?


pip 安装的终端输出:

Downloading/unpacking oursql
Downloading oursql-0.9.2.tar.bz2 (113Kb): 113Kb downloaded
Running setup.py egg_info for package oursql

Installing collected packages: oursql
Running setup.py install for oursql
skipping 'oursqlx/oursql.c' Cython extension (up-to-date)
building 'oursql' extension
/usr/local/mysql-5.5.14-osx10.6-x86_64/bin/mysql_config --cflags
llvm-gcc-4.2 -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 -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c oursqlx/oursql.c -o build/temp.macosx-10.7-intel-2.7/oursqlx/oursql.o -I/usr/local/mysql-5.5.14-osx10.6-x86_64/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64
oursqlx/oursql.c: In function ‘__pyx_pf_6oursql_10Connection___cinit__’:
oursqlx/oursql.c:4630: warning: implicit conversion shortens 64-bit value into a 32-bit value
oursqlx/oursql.c: In function ‘__pyx_pf_6oursql_10_Statement_execute’:
oursqlx/oursql.c:10219: warning: implicit conversion shortens 64-bit value into a 32-bit value
oursqlx/oursql.c: In function ‘__pyx_pf_6oursql_16_DBAPITypeObject___richcmp__’:
oursqlx/oursql.c:17597: warning: implicit conversion shortens 64-bit value into a 32-bit value
llvm-gcc-4.2 -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 -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c oursqlx/compat.c -o build/temp.macosx-10.7-intel-2.7/oursqlx/compat.o -I/usr/local/mysql-5.5.14-osx10.6-x86_64/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64
/usr/local/mysql-5.5.14-osx10.6-x86_64/bin/mysql_config --libs
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/oursqlx/oursql.o build/temp.macosx-10.7-intel-2.7/oursqlx/compat.o -o build/lib.macosx-10.7-intel-2.7/oursql.so -L/usr/local/mysql-5.5.14-osx10.6-x86_64/lib -lmysqlclient -lpthread
ld: warning: ignoring file build/temp.macosx-10.7-intel-2.7/oursqlx/oursql.o, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file build/temp.macosx-10.7-intel-2.7/oursqlx/compat.o, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /usr/local/mysql-5.5.14-osx10.6-x86_64/lib/libmysqlclient.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

Successfully installed oursql
Cleaning up...

最佳答案

这完成了工作:

export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"

关于python - 在 Mac OS Lion 上安装 oursql 成功,但在 python 中导入失败。 **为什么?**,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6780350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com