Problem with Django startproject: TypeError: '_sre.SRE_Match' object is not subscriptable

98 Views Asked by At

Trying to run

django-admin startproject mysite

and there occurs such problem

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

I guess there is a problem with versions, but don't know exactly what is it.

On version 1.8.6 everything is ok, but when I try to use

from django.urls import path, include

I see that there is no django.urls in this version.

So I'd like to use the latest version and will be grateful, if you can help me!

Python version:

Python 3.6.0a4 
1

There are 1 best solutions below

0
On

It seems that you use an unofficial version of django. Hello, try this first, dont remove anything leave pip do it for you:

pip install -U django

Now After that rerun startproject command line