I’d really appreciate help with this error running hello.py. I can’t find a solution to this error. I have tried upgrading, re-installing, and starting a clean environment: I even upgraded jinja2

I’d really appreciate help with this error running hello.py. I can’t find a solution to this error. I have tried upgrading, re-installing, and starting a clean environment: I even upgraded jinja2 and

streamlit run hello.py
Traceback (most recent call last):
  File "python/py3.6/venv/360scene/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/streamlit/__init__.py", line 76, in <module>
    from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/streamlit/delta_generator.py", line 41, in <module>
    from streamlit.elements.altair import AltairMixin
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/streamlit/elements/altair.py", line 26, in <module>
    import altair as alt
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/__init__.py", line 4, in <module>
    from .vegalite import *
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/vegalite/__init__.py", line 2, in <module>
    from .v4 import *
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/vegalite/v4/__init__.py", line 2, in <module>
    from .schema import *
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/vegalite/v4/schema/__init__.py", line 2, in <module>
    from .core import *
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/vegalite/v4/schema/core.py", line 4, in <module>
    from altair.utils.schemapi import SchemaBase, Undefined, _subclasses
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/utils/__init__.py", line 13, in <module>
    from .html import spec_to_html
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/altair/utils/html.py", line 80, in <module>
    """
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/environment.py", line 1208, in __new__
    return env.from_string(source, template_class=cls)
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/environment.py", line 1092, in from_string
    return cls.from_code(self, self.compile(source), gs, None)
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/environment.py", line 749, in compile
    source = self._parse(source, name, filename)
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/environment.py", line 606, in _parse
    return Parser(self, source, name, filename).parse()
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/parser.py", line 1038, in parse
    result = nodes.Template(self.subparse(), lineno=1)
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/parser.py", line 1021, in subparse
    rv = self.parse_statement()
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/parser.py", line 175, in parse_statement
    return f()  # type: ignore
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/parser.py", line 255, in parse_if
    node = result = nodes.If(lineno=self.stream.expect("name:if").lineno)
  File "python/py3.6/venv/360scene/lib/python3.6/site-packages/jinja2/lexer.py", line 405, in expect
    if not self.current.test(expr):
AttributeError: 'Token' object has no attribute 'test'
(360scene) admin@machine:website/neuralstyle/neural_style$

Hi @memyselfandi, welcome to the Streamlit community!

What operating system and version of Streamlit is this? You should be able to do this using pip list.

Best,
Randy

Thanks for the welcome! I am trying to use vncviewer to connect to a remote ubuntu system running streamlit 0.84.1

Thanks, I think we can eliminate vncviewer from the equation, since the error appears to be happening in Ubuntu.

From this StackOverflow post, people seem to indicate that Jinja 3.0.1 could be the issue:

You’re using Python 3.6…streamlit hello was successful for me in a clean environment with Python 3.7 and Jinja 3.0.1. So what I would do is in your environment, run pip install jinja==2.11 and see if things get fixed.

If so, then it looks like this is an unfortunate interaction between jinja and Python, not necessarily streamlit and jinja.

Best,
Randy

1 Like

python 3.7 works just fine. Thanks!

1 Like