Problems encountered when Python+Django+Mysql project is transferred from Windows to Mac

Recently, I made a platform for displaying automated test reports. It is implemented with python3+django+mysql. It is mainly developed on Windows. I encountered some problems when running on Mac. Let me record it here~

The environment that the project depends on is:

JDK/SDK(adb)/Appium/Mysql/python/Android emulator or real machine

  • JDK and SDK installation and configuration environment variables
  • Related to installing mysql : create database + account password consistent with the configuration in the project + database migration (python3 manage.py makemigrations and python3 manage.py migrate)

Encountered the following problem:


AttributeError: 'str' object has no attribute 'decode' File "manage.py", line 16
    ) from exc
         ^
SyntaxError: invalid syntax

Solution : start python manage.py runserver on Windows, and python3 manage.py runserver on Mac


django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

Solution : Add pymysql.version_info=(1,3,13,"final",0) to __init__.py under the project
insert image description here


  File "/Library/Python/3.7/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'

Solution : Change query = query.decode(errorre='replace') to query = query.encode(errorre='replace')
(I wrote it in the form of try except to keep the original content)
insert image description here

Guess you like

Origin blog.csdn.net/wzx77/article/details/107032289
Recommended