Does anyone have any experience using the python library Refextract, package index here. I'm using python 3.4 in Spyder 3.0.0. Pip install went fine, it said the installation was succesfull, in the correct folder (in the Libs/Site packages/ folder). But when I try to load it, it throws in a error message, and I can't really figure out what it means.
Here is my code snippet: from refextract import extract_journal_reference
(as displayed in the manual), which gives the following error:
from refextract import extract_journal_reference
File "C:\path\to\python-3.4.3.amd64\lib\site-packages\refextract\references\api.py", line 96
raise FullTextNotAvailableError("URL not found: '{0}'".format(url)), None, sys.exc_info()[2]
^
SyntaxError: invalid syntax
This is just the importing, not yet the specifying of the link. Does anyone know what to do with this error?
The code that raises the exception is using syntax which is valid in Python2, but not in Python3.
In Python2, it is possible to associate an arbitrary traceback with an exception with this variation of the raise
statement.
raise FooError, 'A foo has happened', a_traceback_object
or as in this case:
raise FooError('A foo has happened'), None, a_traceback_object.
In Python3, the traceback object must be explicitly assigned to the exception's __traceback__
attribute:
ex = FooError('A foo has happened')
ex.__traceback__ = a_traceback_object
raise ex
See PEP 3109 for discussion of this change (summary: reduce the number of different ways of using raise
).
As far as I can see, the package does not claim to be python3-compliant, so you need to run it with Python2 (specifically, 2.7).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With