Getting Importerror: Cannot Import Name Ordereddict
I am getting the error ImportError: cannot import name OrderedDict while installing a server locally on my ubuntu 14.04 machine.I have tried installing ordereddict manually and
Solution 1:
This solved my problem:
here is log:
(virtualEnv) D:\Project\staging\modone\settings>pip install django-celery
Collecting django-celery
Downloading django_celery-3.2.1-py2-none-any.whl (63kB)
100% |################################| 71kB 83kB/s
Collecting django>=1.8 (from django-celery)
Using cached Django-1.10.5-py2.py3-none-any.whl
Collecting celery<4.0,>=3.1.15 (from django-celery)
Downloading celery-3.1.25-py2.py3-none-any.whl (526kB)
100% |################################| 532kB 122kB/s
Requirement already satisfied: pytz>dev in d:\project\installations\virtualenv\lib\site-packages (from celery<4.0,>=3.1.15->django-celery)
Collecting kombu<3.1,>=3.0.37 (from celery<4.0,>=3.1.15->django-celery)
Using cached kombu-3.0.37-py2.py3-none-any.whl
Collecting billiard<3.4,>=3.3.0.23 (from celery<4.0,>=3.1.15->django-celery)
Downloading billiard-3.3.0.23-cp27-none-win32.whl (102kB)
100% |################################| 102kB 114kB/s
Requirement already satisfied: anyjson>=0.3.3 in d:\project\installations\virtualenv\lib\site-packages (from kombu<3.1,>=3.0.37->celery<4.0,>=3.1.15->
django-celery)
Collecting amqp<2.0,>=1.4.9 (from kombu<3.1,>=3.0.37->celery<4.0,>=3.1.15->django-celery)
Using cached amqp-1.4.9-py2.py3-none-any.whl
Installing collected packages: django, amqp, kombu, billiard, celery, django-celery
Found existing installation: Django 1.4.5
Uninstalling Django-1.4.5:
Successfully uninstalled Django-1.4.5
Found existing installation: amqp 1.0.13
Uninstalling amqp-1.0.13:
Successfully uninstalled amqp-1.0.13
Found existing installation: kombu 2.5.16
Uninstalling kombu-2.5.16:
Successfully uninstalled kombu-2.5.16
Found existing installation: billiard 2.7.3.28
Uninstalling billiard-2.7.3.28:
Successfully uninstalled billiard-2.7.3.28
Found existing installation: celery 3.0.18
Uninstalling celery-3.0.18:
Successfully uninstalled celery-3.0.18
Successfully installed amqp-1.4.9 billiard-3.3.0.23 celery-3.1.25 django-1.10.5 django-celery-3.2.1 kombu-3.0.37
Solution 2:
I had this same problem on python 2.7.8 with kombu 4.0.x and I solved it by downgrading kombu to 3.0.x (which was the version I needed).
Didn't have time to investigate the reason of the issue, but this might be related...
Solution 3:
The ImportError
would also occur, if it is not correctly imported (such as with orderedDict
, Ordereddict
, or ordereddict
):
Method 1
from collections import OrderedDict
d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2}
# dictionary sorted by keyprint(OrderedDict(sorted(d.items(), key=lambda t: t[0])))
print(OrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)]))
Method 2
import collections
d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2}
# dictionary sorted by keyprint(collections.OrderedDict(sorted(d.items(), key=lambda t: t[0])))
print(collections.OrderedDict(
[('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)]))
Output
OrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)])
OrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)])
Post a Comment for "Getting Importerror: Cannot Import Name Ordereddict"