MySQLdb ImportError: libmysqlclient.so.18解决方法
安装MySQLdb后,import MySQLdb出错如下:
代码如下:
[root@lizhong MySQL-python-1.2.3]# /usr/local/bin/python2.7 Python 2.7.6 (default, Apr 10 2014, 15:45:39) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /soft/MySQL-python-1.2.3 is being added to sys.path Traceback (most recent call last): File "<stdin>", line 1, in <module> File "MySQLdb/__init__.py", line 19, in <module> import _mysql File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module> File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__ ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
根据最后提示,应该是找不着一个交libmysqlclient.so.18的文件,于是到mysql安装目录里找到这个文件并且做一个软连接到/usr/lib
代码如下:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
如果是64系统则:
代码如下:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
再次import MySQLdb就正常了:
代码如下:
[root@lizhong MySQL-python-1.2.3]# /usr/local/bin/python2.7 Python 2.7.6 (default, Apr 10 2014, 15:45:39) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>>
相关推荐
暗夜之城 2020-06-01
retacnyue 2020-04-15
joyjoy0 2020-04-14
Yasin 2020-02-13
azhou 2019-12-27
kuwoyinlehe 2019-12-26
cyhgogogo 2019-12-10
xiaohong000 2015-02-24
txt 2019-10-22
SuperITPro 2019-09-06
sofast 2019-09-05
LucyGill 2015-02-24
LinuxCard 2015-02-25
boxifeng 2010-11-17
manongpengzai 2019-06-27
JasonYeung 2019-06-28
bcbeer 2014-01-06
西瓜皮儿的皮儿 2009-03-21
山顶冻人 2019-06-12