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

后端 未结 6 888
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 04: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 try

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 04:43

    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 "", line 1, in 
      File "/tmp/pip-build-Y7RFpJ/mysql-python/setup.py", line 17, in 
        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

提交回复
热议问题