Search code examples
pythondjangodjango-manage.pymanage.py

Python 2.6 on MacOSX - ImportError: No module named _collections


I'm a little bit baffled by this error I'm getting when I try to runserver or syncdb - the server was running just fine the other night when I last logged on, so I have no idea why all of a sudden it's not working. Google gave me the following page but it doesn't really address my issue.

Let me know if you need more if the console information below isn't enough. I really am not very efficient with django yet, complete beginner really, and I'm not sure why this isn't working.

Pythoness-410:auth gfleche$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 1, in <module>
    import collections
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/collections.py", line 8, in <module>
    from _collections import deque, defaultdict
ImportError: No module named _collections

Thank you so much and let me know.


Solution

  • Django is attempting to issue the following command (or some variant of it):

    import collections
    

    And is failing. This could be because your installation is missing components . You can verify it's not a django related issue by doing the following:

    Pythoness-410:auth gfleche$ python
    >>> import collections
    

    If you get an error back, then it's likely to be an issue with your python installation - since collections has been around for some time, and is part of the standard install.