如果我的一个程序在Python 2.4中运行,但导入了需要Python 2.5的内容怎么办?
那我该怎么导入这个呢?我现在用的是Python 2.4,但我的一个脚本需要导入xml.etree.ElementTree这个模块,而这个模块只在Python 2.5中有。
5 个回答
2
你应该可以为Python 2.4安装ElementTree。它在Debian系统中叫做 python2.4-elementtree
(还有 ..-celementtree
)。
如果你在你的操作系统中找不到这个软件包,你可以直接从源代码安装。
6
考虑一下在未来的某个时候升级到Python 2.5(或者,敢说的话,2.6!)吧... 时代在变!与此同时,特别是对于ElementTree这个库,你可能可以尝试去修补它,但是...
Come gather 'round people
Wherever you roam
And admit that the waters
Around you have grown
And accept it that soon
You'll be drenched to the bone.
If your time to you
Is worth savin'
Then you better start swimmin'
Or you'll sink like a stone
For the times they are a-changin'.
如果听着好音乐能帮助你,那就随意吧...不过你最好开始努力,不然就会像石头一样沉下去...!-)
4
然后它就失败了。
你不能在运行Python 2.4的时候去导入一个Python 2.5的库。这是行不通的。
那为什么你不能运行Python 2.5或更高版本呢?