2

Using django-admin startproject trydjango gives error:

AttributeError: module 'collections' has no attribute 'Iterator'

even though I have Django installed and could see a list of commands by doing django-admin.

Here is the full error:

Traceback (most recent call last):
  File "/Users/Person/Dev/trydjango/bin/django-admin", line 8, in <module>
    sys.exit(execute_from_command_line())
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/commands/startproject.py", line 20, in handle
    super().handle('project', project_name, target, **options)
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/management/templates.py", line 117, in handle
    django.setup()
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/__init__.py", line 16, in setup
    from django.urls import set_script_prefix
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/urls/__init__.py", line 1, in <module>
    from .base import (
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/urls/base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/urls/exceptions.py", line 1, in <module>
    from django.http import Http404
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/http/__init__.py", line 5, in <module>
    from django.http.response import (
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/http/response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/serializers/__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/core/serializers/base.py", line 6, in <module>
    from django.db import models
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/db/models/__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/db/models/aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/db/models/expressions.py", line 486, in <module>
    class TemporalSubtraction(CombinedExpression):
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/db/models/expressions.py", line 487, in TemporalSubtraction
    output_field = fields.DurationField()
  File "/Users/Person/Dev/trydjango/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 155, in __init__
    if isinstance(choices, collections.Iterator):
AttributeError: module 'collections' has no attribute 'Iterator'

I am following this tutorial and using exactly what's mentioned in there but still, I get this error while the teacher doesn't. Using macOS too.

aaron
  • 39,695
  • 6
  • 46
  • 102
Honesty' Best
  • 29
  • 1
  • 2

2 Answers2

0

Try to use another name for your project.

CommandError: 'test' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.

Khanzadeh_AH
  • 139
  • 6
0

This error may be beacause of env.I have same problem. Make new env and then try to make new project.

Nikhil Kotiya
  • 154
  • 2
  • 9