试着跑
django-admin startproject mysite然后就会出现这样的问题
Traceback (most recent call last):
File "/Users/username/Desktop/test/venv/bin/django-admin", line 10, in <module>
sys.exit(execute_from_command_line())
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/commands/startproject.py", line 20, in handle
super().handle('project', project_name, target, **options)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/core/management/templates.py", line 158, in handle
template = Engine().from_string(content)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/engine.py", line 136, in from_string
return Template(template_code, engine=self)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/base.py", line 155, in __init__
self.nodelist = self.compile_nodelist()
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/base.py", line 193, in compile_nodelist
return parser.parse()
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/base.py", line 447, in parse
filter_expression = self.compile_filter(token.contents)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/base.py", line 563, in compile_filter
return FilterExpression(token, self)
File "/Users/username/Desktop/test/venv/lib/python3.6/site-packages/django/template/base.py", line 638, in __init__
var, constant = match['var'], match['constant']
TypeError: '_sre.SRE_Match' object is not subscriptable我猜是版本有问题,但不知道具体是什么。
在版本1.8.6上,一切正常,但当我尝试使用
from django.urls import path, include我看到这个版本中没有django.urls。
所以我想使用最新的版本,如果你能帮助我,我将不胜感激!
Python版本:
Python 3.6.0a4 发布于 2020-11-27 15:06:33
看起来您使用的是django的非官方版本。你好,先试试这个,不要删除任何东西,让pip为你做:
pip install -U django现在,重新运行startproject命令行
https://stackoverflow.com/questions/65030950
复制相似问题