2016-10-03 79 views
-1

我正在使用一些给我的python代码,并且它在我的系统上失败。特别是在from collections import OrderedDict的资本O和资本D. 的声明但如果我更改声明为import ordereddict它不会失败。 如果我尝试import OrderedDict,它会失败并显示未找到错误。from collections import OrderedDict and python version

我的版本的python是每个SuSE SLES SDK 11.4 2.6.9。 我试图执行的python我相信是为Python的早期版本2.6.x编写的。

是这个问题我遇到了python版本的直接结果吗? 有没有人有任何建议如何正确解决这个问题? OrderedDictordereddict之间是否有差别,是否来自collections

+0

版本2.7中的OrderedDict' [出现](https://docs.python.org/2/library/collections.html#collections.OrderedDict)。 – skovorodkin

+1

相关:[OrderedDict为旧版本的Python](http://stackoverflow.com/questions/1617078/ordereddict-for-older-versions-of-python) – Wondercricket

+0

阅读罚款[文档](https:// docs。 python.org/2/library/collections.html?highlight=Equivalent#collections.OrderedDict),它告诉你它在什么版本中被引入,以及在哪里可以找到**版本的**等价OrderedDict配方**。 – martineau

回答

2

小写字母表示较老的python版本,必须单独安装。相关问题:OrderedDict for older versions of python

+0

所以SLES 11.4有python 2.6.9的小写ordereddict,但没有新的OrderedDict。 – ron

+0

有人可以指向我的手动下载OrderedDict python包的正确网站吗? – ron

+0

要尝试由https://pypi.python.org/pypi/ordereddict的Raymond Hettinger撰写ordereddict1.1.tar.gz。描述是:Py2.7新集合的替代替代品** OrderedDict **在Python 2.4-2.6 – ron