我遇到以下问题:

>>> from owslib.wms import WebMapService
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\owslib\wms.py", line 26, in <module>
    from .etree import etree
  File "C:\Python34\lib\site-packages\owslib\etree.py", line 48, in <module>
    patch_well_known_namespaces(etree)
  File "C:\Python34\lib\site-packages\owslib\etree.py", line 31, in patch_well_k
nown_namespaces
    for k, v in ns.get_namespaces().iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

已安装的库:
---
Name: lxml
Version: 3.3.3
Location: c:\python34\lib\site-packages\lxml-3.3.3-py3.4-win32.egg
Requires:
---
Name: OWSLib
Version: 0.8.13
Location: c:\python34\lib\site-packages
Requires: python-dateutil, pytz

如果有任何解决方法的想法,我将不胜感激。

最佳答案

dict.iteritems仅在Python 2.x中出现,当dict.items返回列表时返回。但是,在Python 3.x中,将dict.items更改为返回view object,所以dict.iteritems was removed也是如此,因为不再需要它。

这意味着您使用的OWSLib版本是为Python 2.x制作的,因此与Python 3.x不兼容。您需要使用Python 2.x或安装可以使用Python 3.x的OWSLib版本。

08-25 22:32