MySQLdbImportError:libmysqlclient.so.18解決方法
來源:懂視網(wǎng)
責編:小采
時間:2020-11-27 14:30:49
MySQLdbImportError:libmysqlclient.so.18解決方法
MySQLdbImportError: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
導讀MySQLdbImportError: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
安裝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 "
", line 1, in
File "MySQLdb/__init__.py", line 19, in
import _mysql
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in
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
根據(jù)最后提示,應該是找不著一個交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
>>>
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
MySQLdbImportError:libmysqlclient.so.18解決方法
MySQLdbImportError: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