Skip to content Skip to sidebar Skip to footer

Error Loading Mysqldb Module: Libmysqlclient.so.20: Cannot Open Shared Object File: No Such File Or Directory

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

Solution 1:

reinstall the c shared library:

pip uninstall mysql-python
pip install mysql-python

Solution 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_configlibs= 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

Solution 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.

Solution 4:

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

exportLD_LIBRARY_PATH=/usr/local/mysql/lib

Solution 5:

In my case the problem was caused by Ubuntu upgrades, so I can't find libmysqlclient.so.20 in /usr/lib/x86_64-linux-gnu.

Answer :

  1. Check existance libmysqlclient.so.XX in /usr/lib/x86_64-linux-gnu (or similar)
  2. Download libmysqlclient.so.XX from Ubuntu website (eg. link for v20)
  3. Install lib using dpkg command sudo dpkg -i libmysqlclient(...).deb and sudo apt-get install -f
  4. Link lib: ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.XX.so libmysqlclient.XX.so

Post a Comment for "Error Loading Mysqldb Module: Libmysqlclient.so.20: Cannot Open Shared Object File: No Such File Or Directory"