question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Used to work on my previous setup reran now and it broke at the cache line

See original GitHub issue

Summary

<streamlit.DeltaGenerator.DeltaGenerator object at 0x000002973C6457C8>
>>> @st.cache(persist=True)
... def load_data(nrows):
...     data = pd.read_csv(r'C:\Users\HendriC\Desktop\LocationTransaction2.csv', nrows=nrows)    
...     lowercase = lambda x: str(x).lower()
...     data.rename(lowercase, axis="columns", inplace=True)
...     data = data.rename(columns={'latitude': 'lat', 'longitude': 'lon'})
...     data[DATE_TIME] = pd.to_datetime(data[DATE_TIME])
...     return data
... 
>>> data = load_data(100000)
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 444, in _to_bytes
    if self._file_should_be_hashed(obj.__code__.co_filename):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 333, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 553, in _get_main_script_directory
    main_path = __main__.__file__
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\caching.py", line 464, in wrapped_func
    return get_or_set_cache()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\caching.py", line 430, in get_or_set_cache
    code_hasher.update(func)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 280, in update
    self._update(self.hasher, obj, context)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 323, in _update
    b = self.to_bytes(obj, context)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 307, in to_bytes
    b = self._to_bytes(obj, context)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 500, in _to_bytes
    raise InternalHashError(msg).with_traceback(e.__traceback__)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 444, in _to_bytes
    if self._file_should_be_hashed(obj.__code__.co_filename):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 333, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\streamlit\hashing.py", line 553, in _get_main_script_directory
    main_path = __main__.__file__
streamlit.errors.InternalHashError: module '__main__' has no attribute '__file__'

Usually this means you found a Streamlit bug! If you think that’s the case, please [file a bug report here.]

Steps to reproduce

@st.cache(persist=True)
def load_data(nrows):
    data = pd.read_csv(r'C:\Users\HendriC\Desktop\LocationTransaction2.csv', nrows=nrows)    
    lowercase = lambda x: str(x).lower()
    data.rename(lowercase, axis="columns", inplace=True)
    data = data.rename(columns={'latitude': 'lat', 'longitude': 'lon'})
    data[DATE_TIME] = pd.to_datetime(data[DATE_TIME])
    return data

What are the steps we should take to reproduce the bug:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’

Expected behavior:

Explain what you expect to happen when you go through the steps above, assuming there were no bugs.

Actual behavior:

Explain the buggy behavior you experience when you go through the steps above. If applicable, add screenshots to help explain your problem.

Is this a regression?

That is, did this use to work the way you expected in the past? yes / no

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Additional information

If needed, add any other context about the problem here. For example, did this bug come from https://discuss.streamlit.io or another site? Link the original source here!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ajscommented, Feb 10, 2021

Looks like this issue has been abandoned, but we’re still seeing this… Not sure where to go.

1reaction
nthmostcommented, Feb 11, 2021

Hi all – We’re going to take another stab at this one! The issue last year was that we (well, I) was unable to reproduce this. Chances are high that I was hung up on this being a Windows issue, but it would appear with further user reports that this applies to other OSes as well.

@bh-streamlit is taking a look!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Repair failed installations of Exchange Cumulative and ...
This article describes the methods to verify the installation of Microsoft Exchange Server Cumulative Updates (CUs) and Security Updates (SUs) ...
Read more >
Last used cache line versus different cache lines
Here is a problem scenario: An array M has a row length that is a multiple of the distance that results in addresses...
Read more >
How a Jenkins Job Broke our Jenkins UI - Slack Engineering
Broken UI: A little history. As part of our automation setup, we continuously run integrity jobs to inspect our Jenkins nodes. These jobs...
Read more >
How to Install and Setup W3 Total Cache for Beginners
Editor's Note: We don't use W3 Total Cache on our website anymore and have switched to WP Rocket which is a premium caching...
Read more >
The Elements of Cache Programming Style - USENIX
This is the simplest and most important view of a cache memory. Its lesson is two-fold: pack as much into a cache line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found