I'm trying out AlchemyAPI_Python-0.6 - PyXml module. I was trying to run the keyword extractor feature of it, but got the following error when trying to compile. I used the keywords.py file given in the examples. I copied all the files underneath the python directory (AlchemyAPI.py, keywords.py, api_key.txt).
Traceback (most recent call last):
File "C:\Python26\keywords.py", line 4, in <module>
import AlchemyAPI
File "C:\Python26\AlchemyAPI.py", line 6, in <module>
from xml import xpath
File "C:\Python26\lib\site-packages\_xmlplus\xpath\__init__.py", line 112, in <module>
from pyxpath import ExprParserFactory
File "C:\Python26\lib\site-packages\_xmlplus\xpath\pyxpath.py", line 59, in <module>
from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
File "C:\Python26\lib\site-packages\_xmlplus\xpath\ParsedAbbreviatedRelativeLocationPath.py", line 31
as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
^
SyntaxError: invalid syntax
Can some one help me out with this issue, please?
Thank you in advance!
PyXML was written for Python 2.4, and the
as
keyword was introduced gradually in Python 2.5 and 2.6. In the last line of the stack trace above, theas
keyword is used as a variable name, which conflicts with the syntax of Python 2.6.You can solve this issue by editing two files, changing the name of the
as
variable to something else (e.g.axis
):C:\Python26\lib\site-packages\_xmlplus\xpath\ParsedAbbreviatedRelativeLocationPath.py
, lines 31 and 32:C:\Python26\lib\site-packages\_xmlplus\xpath\ParsedAbbreviatedAbsoluteLocationPath.py
, lines 27 and 28: