ImportError: cannot import name 'JS_GATENLP_URL' from 'gatenlp.serialization.default'
obkhan opened this issue · 6 comments
Please give all details about your system and software used:
- Operating System: MacOS
- Python Version:3.7
- How was gatenlp installed:
pip
Describe the bug
After trying to run stanza_annotator:
--------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/IPython/core/formatters.py](https://localhost:8080/#) in __call__(self, obj)
336 method = get_real_method(obj, self.print_method)
337 if method is not None:
--> 338 return method()
339 return None
340 else:
1 frames
[/usr/local/lib/python3.7/dist-packages/gatenlp/document.py](https://localhost:8080/#) in _show_colab(self, htmlid, display, annsets, doc_style, row1_style, row2_style)
931 def _show_colab(self, htmlid=None, display=False, annsets=None, doc_style=None,
932 row1_style=None, row2_style=None):
--> 933 from gatenlp.serialization.default import JS_GATENLP_URL, JS_JQUERY_URL
934 from IPython.display import display_html, Javascript
935 from IPython.display import display as i_display
ImportError: cannot import name 'JS_GATENLP_URL' from 'gatenlp.serialization.default' (/usr/local/lib/python3.7/dist-packages/gatenlp/serialization/default.py)
To Reproduce
Steps and/or code to reproduce the behavior.
from gatenlp import Document
from gatenlp.lib_stanza import AnnStanza
stanza_annotator = AnnStanza(lang="en")
doc = Document.load("example.txt")
doc = stanza_annotator(doc)
doc
Thank you for reporting this bug!
Could I ask you to please provide:
- the exact version installed (
import gatenlp
thenprint(gatenlp.__version__
) - the exact way you installed with pip (which extras, if any? e.g.
pip install gatenlp
vspip install gatenlp[stanza]
etc)
- the exact version installed (import gatenlp then print(gatenlp.version)
gatenlp 1.0.7 - the exact way you installed with pip (which extras, if any? e.g. pip install gatenlp vs pip install gatenlp[stanza] etc)
I got the same error after trying , pip install gatenlp , pip install gatenlp[all], pip install gatenlp[stanza]
one other mention I'm using google colab
I think the problem may be related with the exact environment where you want to show the document:
which environment are you in (ipython, python, running a program using python program.py
, a jupyter notebook, jupyter lab, spyder, .... )
Is the code actually running on a Mac or in a browser showing a jupyter or colab notbook running possibly on a different server?
@johann-petrak - I believe you are right, it's perhaps an compatibility issue with google colab
I tried a fresh install of python and using a local jupyter notebook and downloaded the example :
https://gatenlp.github.io/python-gatenlp/lib_stanza.ipynb
then ran -
jupyter notebook
and browsed to the notebook, and ran it - the example worked fine on brew installed python 3.9 / MacOS 12.3.1 !
It's not necessary that I run this in colab, but it may be impactful to someone who may want to try
Thank you - I tried and I can confirm that bug in Google Colab with version 1.0.7.
It does work with the current development version though (you can install that in colab using !pip install -U 'git+https://github.com/GateNLP/python-gatenlp.git#egg=gatenlp[stanza]'
So this should be fixed in the next, upcoming release.
Closing for now as the problem appears to be fixed on the development branch.