-1

I am working with some python code given to me, and it fails on my system. Specifically on the statement of from collections import OrderedDict having a capital O and capital D. But if I change the statement to be import ordereddict it does not fail. And if I try import OrderedDict it fails with a not found error.

My version of python is 2.6.9 per the SuSE SLES SDK 11.4. The python I am trying to execute I believe was written for an earlier 2.6.x version of python.

Is this problem I am experiencing a direct result of the python version? Does anyone have any suggestions how to properly fix this problem? Is there a difference between OrderedDict and ordereddict and whether or not it comes from collections?

ron
  • 967
  • 6
  • 23
  • `OrderedDict` [appeared](https://docs.python.org/2/library/collections.html#collections.OrderedDict) in version 2.7. – skovorodkin Oct 03 '16 at 17:57
  • 1
    Related: [OrderedDict for older versions of python](http://stackoverflow.com/questions/1617078/ordereddict-for-older-versions-of-python) – Wondercricket Oct 03 '16 at 17:58
  • Read the fine [documentation](https://docs.python.org/2/library/collections.html?highlight=Equivalent#collections.OrderedDict) which tells you in what version it was introduced as well as where to find an **Equivalent OrderedDict recipe** for older versions. – martineau Oct 03 '16 at 18:00
  • it seems i am missing some more python libraries, no surprise not the first time with SLES. – ron Oct 03 '16 at 18:08

1 Answers1

2

The lower case one is for older python versions that has to be installed separately. Related question: OrderedDict for older versions of python

Community
  • 1
  • 1
mkj
  • 2,761
  • 5
  • 24
  • 28
  • so SLES 11.4 has lower case ordereddict with python 2.6.9 but does not have the newer OrderedDict. – ron Oct 03 '16 at 18:10
  • Can someone point me to the proper website for manually downloading this OrderedDict python package? – ron Oct 03 '16 at 18:11
  • going to try ordereddict1.1.tar.gz authored by Raymond Hettinger from https://pypi.python.org/pypi/ordereddict. Description is: drop-in substitute for Py2.7's new collections.**OrderedDict** that works in Python 2.4-2.6 – ron Oct 03 '16 at 18:16
  • so the ordereddict1.1.tar.gz does not provide the capital OrderedDict functionality. It seems i need the python 2.7 version of `collections` ? – ron Oct 03 '16 at 18:23