MySQLdb ImportError: libmysqlclient.so.18解決方法
更新時間:2014年08月21日 11:17:44 投稿:junjie
這篇文章主要介紹了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系統(tǒng)則:
復制代碼 代碼如下:
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
>>>
您可能感興趣的文章:
- MySQL錯誤ERROR 2002 (HY000): Can''t connect to local MySQL server through socket
- mysql error:#1062 Duplicate entry ‘***′ for key 1問題解決方法
- MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)問題的解決
- mysql ERROR 1044 (42000): Access denied for user ''''@''localhost'' to database
- mysql登錄報錯提示:ERROR 1045 (28000)的解決方法
- UCenter info: MySQL Query Error SQL:SELECT value FROM [Table]vars WHERE noteexists
- mysql不能啟動報error2013錯誤的多種解決方案
- mysql錯誤處理之ERROR 1786 (HY000)
- winxp 安裝MYSQL 出現Error 1045 access denied 的解決方法
- mysql啟動時出現ERROR 2003 (HY000)問題的解決方法