jsonschema.exceptions._RefResolutionError while trying to use line charts, bar charts or area charts

Summary

Hi, I’m not able to use these particular charts and even the documentation of streamlit is not showing up for some reason. Any reason why just these aren’t working? I’ve been using the example code snippets from the documentation and it’s resulting in the error given in the subject line.

Steps to reproduce

Code snippet:

import streamlit as st
import pandas as pd
import numpy as np


st.write("Hello world")
chart_data = pd.DataFrame(
    np.random.randn(20, 2),
    columns=["a", "c"])

st.bar_chart(chart_data)

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:
Expect to see a Hello World followed by the bar graph

Actual behavior:

Hello World prints out and is followed by an error.
The error that comes up is:

_RefResolutionError: ‘bytes’ object has no attribute ‘timeout’
Traceback:
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\streamlit.py”, line 11, in
st.bar_chart(chart_data)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\runtime\metrics_util.py”, line 356, in wrapped_func
result = non_optional_func(*args, **kwargs)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\elements\dataframe_selector.py”, line 476, in bar_chart
return self.dg._arrow_bar_chart(
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\runtime\metrics_util.py”, line 356, in wrapped_func
result = non_optional_func(*args, **kwargs)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\elements\arrow_altair.py”, line 277, in _arrow_bar_chart
chart = _generate_chart(ChartType.BAR, data, x, y, width, height)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\streamlit\elements\arrow_altair.py”, line 533, in _generate_chart
x_axis_config = alt.Axis(
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\vegalite\v5\schema\core.py”, line 1039, in init
super(Axis, self).init(aria=aria, bandPosition=bandPosition, description=description,
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\utils\schemapi.py”, line 624, in init
self.to_dict(validate=True)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\utils\schemapi.py”, line 807, in to_dict
self.validate(result)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\utils\schemapi.py”, line 924, in validate
return validate_jsonschema(
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\utils\schemapi.py”, line 73, in validate_jsonschema
errors = _get_errors_from_spec(spec, schema, rootschema=rootschema)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\altair\utils\schemapi.py”, line 128, in _get_errors_from_spec
errors = list(validator.iter_errors(spec))
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\jsonschema\validators.py”, line 359, in iter_errors
for error in errors:
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\jsonschema_validators.py”, line 284, in ref
yield from validator._validate_reference(ref=ref, instance=instance)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\jsonschema\validators.py”, line 452, in _validate_reference
scope, resolved = resolve(ref)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\jsonschema\validators.py”, line 1076, in resolve
return url, self._remote_cache(url)
File “C:\Users\Aditya\PycharmProjects\pythonProject1\venv\lib\site-packages\jsonschema\validators.py”, line 1092, in resolve_from_url
raise exceptions._RefResolutionError(exc)

Debug info

  • Streamlit version: 1.24.1
  • Python version: 3.10.7
  • Using PyCharm
  • OS version: windows 11
  • Browser version: microsoft edge and chrome

Hi @Aditya_Nair,

I wasn’t able to reproduce this error when I ran your code. This is what I see when I run the app locally:

Can you share a full list of the packages that are installed in your environment (if you’re using pip, you can do so by entering pip list in the command line)? Can you also confirm that you’re running your app by entering streamlit run <name of your Python file>?

I just found this post because I ran into the exact same error. I updated altair to 5.0.1 and jsonschema to 4.18.1 and it fixed my issue. Apparently tied to this bug: After updating to 4.18.1 earlier code fails with `jsonschema.exceptions._RefResolutionError: 'bytes' object has no attribute 'timeout'` · Issue #1124 · python-jsonschema/jsonschema · GitHub

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.