最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
解决MySQLdb ImportError: libmysqlclient.so.18错误
时间:2014-04-10 编辑:简简单单 来源:一聚教程网
安装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 " 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 |
根据最后提示,应该是找不着一个交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 >>> |
(本文完)
-
上一个: Oracle & mysql的区别整理
-
下一个: mysql远程连接及mysql授权方法
相关文章
- mysql下mysqladmin日常管理命令总结(必看篇) 07-25
- 查看当前mysql使用频繁的sql语句(详解) 07-11
- 对MySql经常使用语句的全面总结(必看篇) 07-11
- 关于mysql init_connect的几个要点总结 07-10
- MySQL外键约束的禁用与启用命令 07-06
- Python使用pymysql小技巧 06-07