近期做了一个展示自动化测试报告的平台,是用python3+django+mysql实现的,主要是在Windows上开发,运行在Mac上遇到了一些问题,这边记录一下~
项目依赖的环境有:
JDK/SDK(adb)/Appium/Mysql/python/安卓模拟器或真机
- JDK和SDK安装及配置环境变量
- 安装mysql相关:创建数据库+账号密码与项目中配置一致+数据库迁移(python3 manage.py makemigrations 和 python3 manage.py migrate)
遇到以下问题:
AttributeError: 'str' object has no attribute 'decode' File "manage.py", line 16
) from exc
^
SyntaxError: invalid syntax
解决方式:Windows上是python manage.py runserver启动,Mac上是python3 manage.py runserver
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
解决方式:在项目下的__init__.py中加入pymysql.version_info=(1,3,13,“final”,0)
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'
解决方式:将query = query.decode(errore=‘replace’)改为query = query.encode(errore=‘replace’)
(我这是为了保留原内容,所以写成了try except的形式)