Syntax error in existing Django project
我第一次安装了现有的Django项目,我遇到启动服务器
这就是我所做的
1.克隆回购,
2.创造一个虚拟环境
3.Pip install requirements.txt
4.生成访问令牌和密钥并放入secrets.sh。 我在
5.Change
1 2 3 4 5 6 7 8 9 10 | DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'USER': 'name', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', } } |
我无法在下面运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | (tag_gen) local_user@local_user:~/Repo/tag_gen/generator$ python manage.py runserver Performing system checks... Unhandled exception in thread started by <function wrapper at 0x7febe4712488> Traceback (most recent call last): File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run self.check(display_num_errors=True) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check include_deployment_checks=include_deployment_checks, File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config return check_resolver(resolver) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver return check_method() File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check for pattern in self.url_patterns: File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns patterns = getattr(self.urlconf_module,"urlpatterns", self.urlconf_module) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module return import_module(self.urlconf_name) File"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File"/home/local_user/Repo/tag_gen/generator/generator/urls.py", line 23, in <module> url(r'^etg/', include('generatorApp.urls', namespace='generatorApp')), File"/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include urlconf_module = import_module(urlconf_module) File"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File"/home/local_user/Repo/tag_gen/generator/generatorApp/urls.py", line 3, in <module> from . import views File"/home/local_user/Repo/tag_gen/generator/generatorApp/views.py", line 170 def view_index(request: WSGIRequest): ^ SyntaxError: invalid syntax |
想法?
您尝试运行的项目是使用Python≥3.5,但您尝试在2.7中运行它。
语法
您需要查找有关如何使用足够高的Python版本创建