explosion/spacy-streamlit

AttributeError: module 'spacy_streamlit' has no attribute 'visualizer'

Code4SAFrankie opened this issue · 2 comments

import spacy_streamlit

models = ["en_core_web_sm", "en_core_web_md"]
default_text = "Sundar Pichai is the CEO of Google."
spacy_streamlit.visualize(models, default_text)

gives the error:

AttributeError: module 'spacy_streamlit' has no attribute 'visualizer'
Traceback:

File "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\streamlit\ScriptRunner.py", line 322, in _run_script
    exec(code, module.__dict__)
File "e:\work\Python\spacy_streamlit.py", line 1, in <module>
    import spacy_streamlit
File "e:\work\Python\spacy_streamlit.py", line 5, in <module>
    spacy_streamlit.visualizer(models, default_text)

I am using Windows 10 WinPython 3.7.1

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32

ines commented

Based on your traceback, it looks like you called your file spacy_streamlit.py, which is the same name as the module spacy_streamlit. This means that your local module (the file) is shadowing the indtalled module (the package). You can read more about this concept here: http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap

If you rename spacy_streamlit.py to something else, it should work as expected 🙂