MySQLdb ImportError: libmysqlclient.so.18解决方法
程序员文章站
2022-05-25 18:22:26
安装mysqldb后,import mysqldb出错如下:
复制代码 代码如下:
[root@lizhong mysql-python-1.2.3]# /usr/lo...
安装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
>>>
上一篇: 数据处理之深浅拷贝完全剖析
下一篇: Python中除法使用的注意事项
推荐阅读
-
MySQLdb ImportError: libmysqlclient.so.18解决方法
-
Python中MYSQLdb出现乱码的解决方法
-
error while loading shared libraries: libmysqlclient.so.18解决方法
-
pycharm运行出现ImportError:No module named的解决方法
-
Django重装mysql后启动报错:No module named ‘MySQLdb’的解决方法
-
安装python时MySQLdb报错的问题描述及解决方法
-
pycharm读取图片,提示ImportError: cannot import name imread解决方法
-
python MySQLdb Windows下安装教程及问题解决方法
-
关于pycharm找不到MySQLdb模块的解决方法
-
PySide2出现“ImportError: DLL load failed: 找不到指定的模块”的问题及解决方法