$ python3 manage.py migrate
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
[...exception stack...]
Did you install mysqlclient?
Except I just bumped down the version condition, instead of doing a pass (pseudo-comment) section on it). Here's the suggested solution that finally worked:
Commenter: This is how I fixed it
Go to your django/db/backends/mysql installation dir. Check your path in the error message.
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)
Like this.
if version < (1, 3, 13):
pass
'''
raise ImproperlyConfigured(
'mysqlclient 1.3.13 or newer is required; you have %s.'
% Database.__version__
)
'''
NB: I just raised the version parameters to let v 0.9.3 pass, like so:
$ vi /home/dpc/.local/lib/python3.6/site-packages/django/db/backends/mysql/basr.py
...to make it:
if version < (0, 9, 3):
raise ImproperlyConfigured(
'mysqlclient 1.3.13 or newer is required; you have %s.'
% Database.__version__
)
Critical! Eliminate the lowest-level exception thrown by decode:
$ python3 manage.py migrate
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
[....Skipping 8 million exception errors!...]
File "/home/dpc/.local/lib/python3.6/site-packages/django/db/backends/mysql/features.py", line 82, in is_sql_auto_is_null_enabled
cursor.execute('SELECT @@SQL_AUTO_IS_NULL')
File "/home/dpc/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 103, in execute
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
File "/home/dpc/.local/lib/python3.6/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
Save, close this file and open operations.py.
$ vi /home/dpc/.local/lib/python3.6/site-packages/django/db/backends/mysql/operations.py
Search for:
query = query.decode(errors='replace')
and change decode to encode
query = query.encode(errors='replace')
Now, try to run the server.
FINALLY!
dpc@LT3-Insp17-2017:~/dpc.data/local.FS/lfs.03-Projects.Active/project.MindCurrent/dev/python/djankysite$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK
Perform the MySQL cofig/hookup per Database Tutorial, then:
Ideas:
DDG: django error Did you install mysqlclient?
SO: Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
SO: Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3
DDG: pip3 error ModuleNotFoundError: No module named 'setuptools'
Solution: per StackExchange (cycles of
pip3
un/re-installs, also involvedapt-get install
):Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
History (so far):
Moving on...
I had a bitch of a time with a shitload of thrown exceptions when trying to run:
python3 manage.py migrate
This was just a shit-show. Python versioning is such a PITA! :unamused:
I thrashed around for a long-ass time using various combinations of these links:
DDG: ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
SO: https://stackoverflow.com/questions/14426491/python-3-importerror-no-module-named-setuptools
DDG: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
SO: Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3
What finally ended up working was this one in particular:
Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3
Except I just bumped down the version condition, instead of doing a pass (pseudo-comment) section on it). Here's the suggested solution that finally worked:
Commenter: This is how I fixed it
Go to your
django/db/backends/mysql
installation dir. Check your path in the error message.I'm using pipenv so my path is:
Open file
base.py
and search for:version = Database.version_info
Put a pass inside if and comment line:
Like this.
Save, close this file and open
operations.py
.This is how I fixed it.
Go to your
django/db/backends/mysql
installation dir. Check your path in the error message.I'm using
pipenv
so my path is:/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql
Open file
base.py
and search for:version = Database.version_info
Put a pass inside if and comment line:
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)
Like this.
NB: I just raised the version parameters to let v 0.9.3 pass, like so:
...to make it:
Critical! Eliminate the lowest-level exception thrown by
decode
:[....Skipping 8 million exception errors!...]
Save, close this file and open
operations.py
.Search for:
query = query.decode(errors='replace')
and change
decode
toencode
query = query.encode(errors='replace')
Now, try to run the server.
FINALLY!
Re-cap of history since last capture: