我按照在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
我想念什么?有什么建议吗?
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...
答案 0 :(得分:6)
这完成了这项工作:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
答案 1 :(得分:0)
如果您不想安装完整的MySQL,可以使用mysql-connector-c编译oursql。
下载mysql-connector-c,解压缩并安装:
wget http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-osx10.5-x86-64bit.tar.gz/from/http://cdn.mysql.com/
tar -xvf mysql-connector-c-6-1.0.2-osx10.5-x86-64bit.tar
cd mysql-connector-c-6.0.2-osx10.5-x86-64bit
sudo cp bin/* /usr/local/bin/
sudo cp lib/* /usr/local/lib/
sudo cp -r include/* /usr/local/include/
下载并解压缩oursql:
wget --no-check-certificate https://launchpad.net/oursql/py3k/py3k-0.9.3/+download/oursql-0.9.3.zip
unzip oursql-0.9.3.zip
编译我们的软件:
cd oursql-0.9.3
sudo python setup.py build_ext
这已经过验证可以与OSX 10.8.2,Xcode 4.5.2和Python 3.2.3一起使用
答案 2 :(得分:0)
我遇到了这个问题,寻找在OSX 10.10.5上安装oursql的解决方案。我之前使用brew brew install mysql
安装了mysql。对于那些希望在yosemite上安装myql的人来说,这对我有用:
1)手动下载包。请参见链接here。
2)在您喜欢的文本编辑器中打开oursql/oursql-0.9.3.1/oursqlx/_exceptions.c
3)评论最后一个“默认”,应该是这样的:
/*default:
if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST)
return _oursqlx_ProgrammingError;
else if (err > CR_MIN_ERROR && err < CR_MAX_ERROR)
return _oursqlx_InterfaceError;*/
4)现在再次尝试运行安装程序:
[sudo] python setup.py install
答案 3 :(得分:-1)
在mac os snow leopard上安装mysql-server的最佳方法是尝试从源文件安装,以确保为正确的体系结构x86_64编译mysql。