Streamlit failed to hash an object
See original GitHub issueI am trying to get the DataFrame Demo from streamlit hello
to work. I am running this using Anaconda and Python 3.6.
I get the following error in the browser:
Streamlit cannot hash an object of type <class 'os._Environ'>.,
More information: to prevent unexpected behavior, Streamlit tries to detect mutations in cached objects so it can alert the user if needed. However, something went wrong while performing this check.
Please file a bug.
To stop this warning from showing in the meantime, try one of the following:
Preferred: modify your code to avoid using this type of object.
Or add the argument ignore_cache=True to the st.cache decorator.
I get a bunch of additional errors on Streamlit failed to hash an object of type <class 'function'>.,
And then this error blob:
TypeError: object supporting the buffer API required
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/ScriptRunner.py", line 306, in _run_script exec(code, module.__dict__)
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/hello.py", line 334, in <module> run()
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/hello.py", line 308, in run demo()
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/hello.py", line 247, in data_frame_demo df = get_UN_data()
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/caching.py", line 544, in wrapped_func return get_or_set_cache()
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/caching.py", line 509, in get_or_set_cache code_hasher.update(func)
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/hashing.py", line 185, in update self._update(self.hasher, obj, context)
File "/Users/lberndt/anaconda/envs/python3/lib/python3.6/site-packages/streamlit/hashing.py", line 217, in _update hasher.update(b)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:17 (4 by maintainers)
Top Results From Across the Web
UnhashableType: Cannot hash object of type _thread._local
I keep getting the same error returned when I use st.cache before a function doing a complex query & pandas manipulation.
Read more >Caching issues - Streamlit Docs
Streamlit raises this error whenever it encounters a type it doesn't know how to hash. This could be either when hashing the inputs...
Read more >How to cache unsupported objects? - Using Streamlit
I've a function which accepts a MSExperiment instance as argument and I get the error: Streamlit cannot hash an object of type <class...
Read more >Cannot hash object of type _json.Scanner - Using Streamlit
Hi there! I'm using st.cache on this function which requests data from Coin Market Cap and then parses it using Beautiful Soup.
Read more >Hashing error in experimental_memo(), but not cache()
Getting the following error, but the type referenced is clearly hashable (and works with cache() ):. UnhashableParamError : Cannot hash ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same here, macos, conda, python 3.7.4
Released as 0.48.1
More info: When you st.cache a function, Streamlit’s caching mechanism traverses all function calls inside it to track whether the called function’s body was edited since the cached function was last cached. And Streamlit already ignored “library” functions, since those can be assumed to be unmodified.
However, the way we defined library functions was “functions that were defined outside your current working directory its subfolders”. But this broke whenever your Python environment was placed inside the cwd!
So since version 0.48.1 we define “library function” as any function that was defined:
server.folderWatchBlacklist
.In addition, we also added this explanation to our error message:
Of course, this still doesn’t solve the underlying problem of why those library functions were not hashable in the first place. We are working on that right now, but since there are a few different cases where things may not be hashable, I’d rather create one bug for each case than have a long-stanging bug with lots of mixed conversations.
Also, for almost everyone who reported this issue, the script that caused the bug was
streamlit hello
(which we know is 100% hashable!) and the tracebacks provided show the error was always due to library functions not being hashable (which is what we fixed now). So I’ll close this bug now.