Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error loading MySQLdb module.
#1
Hi all,

Apologies, i am new to python and django, this might be a simple question.

I *had* a perfectly working environment using Django and MySQL 8. The Python components were installed via pip3.

From pip3 freeze:
Django==2.1.3
django-filter==2.0.0
django-formtools==2.1
django-widget-tweaks==1.4.2
mysqlclient==1.3.13
My imac recently updated to Mojave, and the whole thing fell apart and issues connecting to MySQL came up.

this is the output from python3 manage.py makemigrations

[i]
Error:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10e4a92f0> Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module> import MySQLdb as Database File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in <module> import _mysql ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so Reason: image not found .... django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?[/i]
So, i have now tried:
Uninstalling and Reinstalling MySQL
Uninstalling and Reinstalling mysqlclient (via pip)
Uninstalling and Reinstalling Django and components (via pip)

i read somewhere that @rpath points to /usr/lib, i have no symbolic link in /usr/lib pointing to /usr/local/mysql/lib where libmysqlclient.21.dylib resides? Maybe thats something to do with it?

No matter what I do, I cant get my environment back up and running again. all the things suggested on google that I have found havent worked.

Has anyone come across this?

Many thanks!
Reply
#2
This error may pop up due to lack of dependencies and libraries. Follow these steps before pip install mysqlclient.
For Debian / Ubuntu
Quote:sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
sudo apt-get install zlib1g-dev
If this didn't worked try checking this Solution for Django MySQLClient pip compile failure on Linux Arrow Heart
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error 404 when loading my webpage dissi 0 119 Mar-20-2024, 03:12 PM
Last Post: dissi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020