Python 2.6 on MacOSX - ImportError: No module named _collections

偶尔善良 提交于 2019-12-08 07:33:50

问题


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.


回答1:


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.




回答2:


Everybody was very helpful and lovely. Turns out there was some sort of issue with my entire Python install - I didn't end up reinstalling my entire OS, but only XCode, since it had been out of date since at least 2010, and this had caused a variety of other issues. Reinstalling XCode with CLI tools, installing Python 2.7, as well as reinstalling homebrew, pip and django solved my issue. Thanks very much everybody. I'm still uncertain what could have happened for my computer to make it work for almost a month and then all of a sudden crash. I'm going to keep looking for the answer why it stopped working in the first place, but I'm so happy I can finally get back to work and my django is back and running smoothly.



来源:https://stackoverflow.com/questions/18107198/python-2-6-on-macosx-importerror-no-module-named-collections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!