1.pip 安装出现 ERROR: Command errored out with exit status 1,如下一连串红色,可观察最后一段
ERROR: Command errored out with exit status 1: 'f:\python3.5.2\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ASUS\\AppData\\Local\\Temp\\pip-install-pwmaog5l\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ASUS\\AppData\\Local\\Temp\\pip-install-pwmaog5l\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ASUS\AppData\Local\Temp\pip-record-pzwne1p9\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
这里可以观察到mysqlclient安装失败,可以去到https://www.lfd.uci.edu/~gohlke/pythonlibs/,去下载whl后缀文件
其中cp35表示python版本为python3.5,win32表示32位,可根据本地安装的python版本去选择
之后将下载的文件放到python路径的scripts文件夹下,之后pip install ***.whl,之后再hi使用pip install mysqlclient可看到已经成功安装
2. pip list查看已经安装的所有包
3. pycharm中运行出现以下错误:AttributeError: 'str' object has no attribute 'decode',此时找到报错的对应py文件中,在decode前边加上encode
4.搭建Django2.0+Python3+MySQL5时同步数据库时报错:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None
解决办法:
找到Python安装路劲下的....\django\db\backends\mysql\base.py文件
将文件中的如下代码注释
重新在项目manage.py路劲下执行如下命令即可
python manage.py makemigrations
python manage.py migrate