简体   繁体   English

从PyXML-0.8.4使用XPath时导入错误

[英]Import error when using XPath from PyXML-0.8.4

I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. 我正在unix工作站上使用Python 2.6.6-64bit学习Xpath和XSLT。 For Xpath, I'm using the xpath module provided in PyXml-0.8.4. 对于Xpath,我使用的是PyXml-0.8.4中提供的xpath模块。

However, the import line itself throws the following error: 但是,导入行本身会引发以下错误:

Traceback (most recent call last):
  File "xp.py", line 7, in <module>
    from xml.xpath          import Evaluate
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/__init__.py", line 112, in <module>
    from pyxpath import ExprParserFactory
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/pyxpath.py", line 59, in <module>
    from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
    as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
     ^
SyntaxError: invalid syntax

Looking it up led me to understand that this is because 'as' is a reserved name in python-2.6 and PyXML-0.8.4 tries to redefine it. 查找它使我理解这是因为“ as”是python-2.6中的保留名称,而PyXML-0.8.4试图重新定义它。 However, there are no directions on how to resolve this issue. 但是,没有有关如何解决此问题的说明。

Please advise. 请指教。

PyXML is obsolete and should not be used (see here ). PyXML已过时,不应使用(请参阅此处 )。 That's why there are no updates for it. 这就是为什么没有更新的原因。 Many features that were included in it were added to Python's standard library. 其中包含的许多功能已添加到Python的标准库中。 There are also fully-supported third-party packages for Python XML processing like lxml . 也有用于Python XML处理的完全支持的第三方程序包,例如lxml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 wsgi + Django:SOAPpy(pyXML)模块导入错误 - wsgi + Django: SOAPpy(pyXML) modules Import Error 在Ubuntu 13.1上安装PyXML之后,我无法导入AdWordsClient - After installing PyXML on Ubuntu 13.1 I can't import AdWordsClient 尝试使用循环从网站导入数据时出错 - Getting Error When Trying to Import Data From Website Using Loop 使用lxml和xpath时出现奇怪的python错误 - Weird python error when using lxml and xpath 使用“导入bs4”或“从bs4导入BeautifulSoup”时出现以下错误 - Error as follow when using 'import bs4', or 'from bs4 import BeautifulSoup' 使用命令“from polyglot.detect import Detector”时出错 - Error when using the command "from polyglot.detect import Detector" 使用 XPath 和 Selenium 打开新选项卡并从该选项卡中抓取内容时出错 - Error when opening new tab and grabbing content from that tab using XPath with Selenium 使用 Xpath 时出现 NoSuchElementException - NoSuchElementException when using Xpath 使用最新的石墨烯和石墨烯-django 版本时导入(无法从“graphql”导入名称“ResolveInfo”)错误 - Import (cannot import name 'ResolveInfo' from 'graphql') error when using newest graphene and graphene-django version 使用 Selenium 抓取债券的最后收盘价时 Xpath 出错 - Error in Xpath when scraping last close price of a bond using Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM