ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

情景:在python中使用mysql

已知:

[[email protected] muahao03]# pip list
Django (1.7.1)
MySQL-python (1.2.5)
pip (1.5.6)
pysqlite (2.6.3)
setuptools (8.2.1)
wsgiref (0.1.2)

已经安装

MySQL-python

报错:

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[[email protected] muahao03]# python
Python 2.7.9 (default, Dec 19 2014, 18:09:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
  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
>>>
[[email protected] muahao03]# service mysql status
 SUCCESS! MySQL running (22804)
[[email protected] muahao03]# netstat -antlpe | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      500        171576     22804/mysqld        
[[email protected] muahao03]# rpm -ql mysql
/usr/bin/msql2mysql
/usr/bin/my_print_defaults
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_find_rows
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/lib64/mysql/mysql_config
/usr/lib64/mysql/mysqlbug
/usr/share/doc/mysql-5.1.73
/usr/share/doc/mysql-5.1.73/COPYING
/usr/share/doc/mysql-5.1.73/README
/usr/share/doc/mysql-5.1.73/README.mysql-docs
/usr/share/doc/mysql-5.1.73/README.mysql-license
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_config.1.gz
/usr/share/man/man1/mysql_find_rows.1.gz
/usr/share/man/man1/mysql_waitpid.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
[[email protected] muahao03]# python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/python2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", line 40, in <module>
    class Permission(models.Model):
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/models/base.py", line 124, in __new__
    new_class.add_to_class(‘_meta‘, Options(meta, **kwargs))
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/models/options.py", line 166, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/utils.py", line 242, in __getitem__
    backend = load_backend(db[‘ENGINE‘])
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/utils.py", line 108, in load_backend
    return import_module(‘%s.base‘ % backend_name)
  File "/usr/local/python2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory

解决:

[[email protected] muahao03]# find / -name libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18

[[email protected] muahao03]# ls -ld /usr/lib64/
dr-xr-xr-x. 50 root root 36864 Dec 23 03:40 /usr/lib64/

[[email protected] muahao03]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 

[[email protected] muahao03]# python
Python 2.7.9 (default, Dec 19 2014, 18:09:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb               
>>>

表的实现,进行数据库同步动作:

再次执行:

又报错:

[[email protected] muahao03]# python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/local/python2.7/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/python2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/muahao03/blog/models.py", line 3, in <module>
    class Employee(models.Model):
  File "/root/muahao03/blog/models.py", line 4, in Employee
    name=models.CharFeild(max_length=20)
AttributeError: ‘module‘ object has no attribute ‘CharFeild‘

[[email protected] muahao03]# python
Python 2.7.9 (default, Dec 19 2014, 18:09:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from blog.models import Employee
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "blog/models.py", line 3, in <module>
    class Employee(models.Model):
  File "blog/models.py", line 4, in Employee
    name = models.CharFeild(max_length=20)
AttributeError: ‘module‘ object has no attribute ‘CharFeild‘
>>>

解决:原因是我把CharField 写成了CharFeild

[[email protected] muahao03]# vim blog/models.py

from django.db import models

class Employee(models.Model):

name = models.CharField(max_length=20)

时间: 2024-10-14 13:08:16

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory的相关文章

Nagios显示器mysql定从库: libmysqlclient.so.18: cannot open shared object file: No such

做mysql的slave时间监控,必须check_mysql文字,check当误差: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory 1,错误信息例如以下:[[email protected] ~]# /usr/local/nagios/libexec/check_mysql -uadmin -P3306 -S

ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory 解决办法

>>> import MySQLdbTraceback (most recent call last):  File "<stdin>", line 1, in <module>  File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>  File "build/bdist.linux-x86_64/eg

sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file

安装编译完后sysbench后,报错. 报错信息: [[email protected] dongbo]# sysbench -v sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory 解决方法: 1. [[email protected] dongbo]# ls -l /usr/local/my

error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such

启动zabbix_server出现如题错误,差点没晕死过去,从前一直没出现,这种错误其实工作上已经遇到过无数次了,但是每次的没有好好记录总结一些,导致每次遇到都需要傻乎乎的跑到网上->百度,方可解决.今天特地针对这个小问题写一篇错误记录博客,日后遇到方可快速查看. 执行命令 cd /usr/local/mysql/lib/ ll libmysqlclient.so 发现有  libmysqlclient.so -> libmysqlclient.so.18 于是 ln -s /usr/loca

php: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No

解决方法: 1.进入mysql安装目录查看,确认有libmysqlclient.so.16.0.0 文件, 于是需要在/usr/lib目录下建立一个软链接来指向libmysqlclient.so.16 2.在php lib目录下下建立个软链接:(格式为:ln -s mysql lib路径  php lib路径) ln -s /home/openpf/app/mysql-5.1.56-2/lib/mysql/libmysqlclient.so.16  /home/openpf/app/php-5.

ImportError: libxml2.so.2: cannot open shared object file: No such file or directory

此错的解决方法就是下载libxml2.so.2 RPM安装:#rpm -ivh libxml2-2.6.26.....rpm

ImportError: libQtTest.so.4: cannot open shared

错误: import cv2 File "/usr/local/lib/python3.5/dist-packages/cv2/__init__.py", line 3, in <module> from .cv2 import * ImportError: libQtTest.so.4: cannot open shared object file: No such file or directory 解决: sudo apt install libqt4-test  

error while loading shared libraries: libreadline.so.5: cannot open shared object file:

错误信息: ftp: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory 解决办法: yum install -y readline-devel readline [[email protected] ~]# cd /usr/lib64/ [[email protected] lib64]# ll *libreadline

libreadline.so.6: cannot open shared object file 问题解决办法

问题描述:在centos 6.4 上执行reboot命令之后,系统启动失败,不能连接.去服务器机房,插上显示器与键盘,屏幕给出报错信息如下: "setting up logical volume management: /sbin/lvm : error while loading shared libraries:  ibreadline.so.6:cannot open shared object file :no such file or directory" 解决办法: 查看/