Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory

匿名 (未验证) 提交于 2019-12-03 02:51:02

问题:

I had a running django project and for some reasons I had to remove the current mysql version and install a different MySQL version in my machine.

But now when I am trying to run this program am getting an error as follows:

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory 

回答1:

reinstall the c shared library:

pip uninstall mysql-python pip install mysql-python 


回答2:

My issue with the same error message was mysql environment not all the way set up. I needed to uninstall MySQL-python; install libmysqlclient-dev; reinstall MySQL-python to rectify the issue.

So the fix was too:

  • sudo pip uninstall MySQL-python (uninstall from your package manager of choice)
  • sudo apt-get install libmysqlclient-dev

  • sudo pip install MySQL-python

**I should also mention that I used the --no-cache-dir option with pip install to hit PYPI directly which helped discover the following:

sh: 1: mysql_config: not found Traceback (most recent call last):   File "<string>", line 1, in <module>   File "/tmp/pip-build-Y7RFpJ/mysql-python/setup.py", line 17, in <module>     metadata, options = get_config()   File "/tmp/pip-build-Y7RFpJ/mysql-python/setup_posix.py", line 43, in get_config     libs = mysql_config("libs_r")   File "/tmp/pip-build-Y7RFpJ/mysql-python/setup_posix.py", line 25, in mysql_config     raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found 

and lead me to here

Using: mysql 5.7, mysql-python 1.2.5, django 1.8.9, ubuntu 16.04



回答3:

Use the following commands:

pip uninstall mysql-python pip install mysql-python 

In my case it work because it searches from the complied files.



回答4:

I did fix the same issue via setting below environment variable:

export LD_LIBRARY_PATH=/usr/local/mysql/lib 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!