安装MySQLdb的问题,找不到shared obect文件

安装MySQLdb的问题,找不到shared obect文件

我自己把MySQL5编译安装在~/mysql50/ 目录下,然后我自己下载了
MySQL-python-1.2.0.tar.gz,按照README的说明安装:
$ tar xfz MySQL-python-1.2.0.tar.gz
$ cd MySQL-python-1.2.0
$ python setup.py build
$ su # or use sudo
# python setup.py install
一切顺利,可是我import MySQLdb时,出错:
Traceback (most recent call last):
File "./mysqldataImport.py", line 6, in ?
import MySQLdb
File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such
file or directory
我发现libmysqlclient_r.so.15在~/mysql50/lib/mysql目录下,请问我该怎么做才能让
Python发现这个库文件?
试试
两种方法:
1. 把~/mysql50/lib/mysql加到LD_LIBRARY_PATH环境变量中(注意把~变成绝对路径)

[Copy to clipboard] [ - ]
CODE:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mysql50/lib/mysql

2. 将建链接到/usr/lib

[Copy to clipboard] [ - ]
CODE:
cd /usr/lib
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so.15
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient.so.15
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient.so

对头,谢一个!


QUOTE:
原帖由 kytexzy 于 2006-3-2 10:16 发表
对头,谢一个!

解决了吗?