Importerror:libmysqlclient.so.18:cannot open Shared object file:no such file or directory

Source: Internet
Author: User
Tags mysql in stdin

Scenario: using MySQL in python

Known:

[[Email protected] muahao03]# pip Listdjango (1.7.1) Mysql-python (1.2.5) pip (1.5.6) pysqlite (2.6.3) setuptools (8.2.1) Wsgiref (0.1.2)


Already installed

Mysql-python


Error:

Importerror:libmysqlclient.so.18:cannot open Shared object file:no such file or directory
[[email protected] muahao03]# pythonpython 2.7.9  (default, dec 19 2014 ,  18:09:06)  [GCC 4.4.7 20120313  (red hat 4.4.7-4)] on linux2type   "Help",  "copyright",  "credits"  or  "license"  for more information.> >> 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/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  mysqltcp        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 syncdbtraceback  (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   &NBSP;&NBSP;__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



Solve:

[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. Root root 36864 Dec 03:40/usr/lib64/[[email protected] muahao03]# ln-s/usr/local/mysql/lib/libmysqlclient.so.18/ usr/lib64/libmysqlclient.so.18 [[email protected] muahao03]# Pythonpython 2.7.9 (default, Dec, 18:09:06) [GCC 4.4. 7 20120313 (Red Hat 4.4.7-4)] on Linux2type ' help ', ' copyright ', ' credits ' or ' license ' for more information.>>> Import MySQLdb >>>



The implementation of the table, the database synchronization action:

Execute again:

Also error:

[[email protected] muahao03]# python manage.py syncdbtraceback  (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 ", &NBSP;LINE&NBSP;108,&NBSP;IN&NBSP;POPULATE&NBsp;   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   &NBSP;&NBSP;__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]# pythonpython 2.7.9  (default, Dec 19 &NBSP;2014,&NBSP;18:09:06)  [gcc 4.4.7 20120313  (red hat 4.4.7-4)] on linux2type  "Help",  "copyright",   "Credits"  or  "license"  for more information.>>> from  blog.models import employeetraceback  (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 ' >>>


Solution: The reason is I wrote Charfield Charfeild

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

From django.db import Models


Class Employee (models. Model):

Name = models. Charfield (MAX_LENGTH=20)







This article from "8176010" blog, declined reprint!

Importerror:libmysqlclient.so.18:cannot open Shared object file:no such file or directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.