我看到MySQLdb存在于我服务器的/opt/xxx/python2.6/site- packages / MySQL_python-1.2.5-py2.6-linux-x86_64.egg / *路径中。
the default paths
/usr/bin/mysql
/usr/bin/python2.6
/usr/lib64/python2.6
/usr/lib64/python2.6/site-packages
在/usr/lib64/mysql/*
下,我看到下面提到的.so文件。
drwxr-xr-x 4 root root 4096 May 2 14:40 .
dr-xr-xr-x. 67 root root 57344 May 2 14:56 ..
-rwxr-xr-x 2 root root 9700193 Feb 1 19:01 libmsql.lib
lrwxrwxrwx 1 root root 24 May 2 13:17 libmysqlclient -> libmysqlclient.so.20.2.0
lrwxrwxrwx 1 root root 24 Mar 25 13:12 libmysqlclient.so.20 -> libmysqlclient.so.20.2.0
-rwxr-xr-x 2 root root 9700193 Feb 1 19:01 libmysqlclient.so.20.2.0
drwxr-xr-x 4 root root 4096 Mar 25 13:13 mecab
lrwxrwxrwx 1 root root 24 May 2 13:17 mysqlclient -> libmysqlclient.so.20.2.0
我试图从/ root运行我的脚本,在其中采用默认路径。我回来时出现以下错误。
Traceback (most recent call last):
File "test.py", line 1, in <module>
import MySQLdb
File "/opt/cloudera/parcels/CDH-5.6.0- 1.cdh5.6.0.p0.45/lib/hue/build/env/lib/python2.6/site-packages/MySQL_python- 1.2.5-py2.6-linux-x86_64.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
有人可以纠正我并帮助解决这个问题。我应该设置任何环境变量,以便可以导入模块。