发布时间:2019-08-07 14:07:05编辑:auto阅读(1536)
最近在学习pythonTDD(测试驱动开发时)遇到了一个问题,根据指导需要使用Django1.12版本,但是在跑服务启动命令
python manage.py runserver
的时候,出现了如下的报错:
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/robot/.virtualenvs/superlists/lib/python3.7/site-packages/django/contrib/admin/__init__.py", line 4, in <module>
from django.contrib.admin.filters import (
File "/Users/robot/.virtualenvs/superlists/lib/python3.7/site-packages/django/contrib/admin/filters.py", line 10, in <module>
from django.contrib.admin.options import IncorrectLookupParameters
File "/Users/robot/.virtualenvs/superlists/lib/python3.7/site-packages/django/contrib/admin/options.py", line 13, in <module>
from django.contrib.admin import helpers, widgets
File "/Users/robot/.virtualenvs/superlists/lib/python3.7/site-packages/django/contrib/admin/widgets.py", line 152
'%s=%s' % (k, v) for k, v in params.items(),
^
SyntaxError: Generator expression must be parenthesized
后来搜索后发现了时python(3.7)和Django(1.12)版本之间的兼容问题,网络上给出的解决方案是安装python3.6。
由于之前使用brew进行包管理和软件安装的,所以想偷个懒。继续使用brew安装python3.6,通过搜索网络获得如下解决方案,原解决方案是:Homebrew: Rollback from Python 3.7 to Python 3.6.5.x? - Ask Different
具体的操作步骤是:
brew unlink python
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
因为之前没有安装python3.6所以在使用一些help的brew switch时并不生效,
根据观察,使用 brew switch命令时,brew回去cell目录中去找,但是由于之前就没安装过,所以自然会失败。
上一篇: CentOS安装Python
下一篇: python数据结构之链表(linked
47494
45794
36793
34324
28968
25598
24443
19611
19111
17632
5466°
6048°
5570°
5638°
6573°
5376°
5378°
5884°
5855°
7170°