aloncohen1 / chat-analyzer

Apply different analysis & data science tools on your Telegram / Whatsapp chat and get exciting insights!
https://chat-anlyzer.streamlit.app
19 stars 7 forks source link

Cannot run #1

Closed dragon74 closed 5 months ago

dragon74 commented 8 months ago

Running python Home.py and getting this error:

2024-01-30 11:54:20.127 WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without streamlit run Traceback (most recent call last): File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 398, in getitem return self._getitem(widget_id, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 443, in _getitem raise KeyError KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 119, in getattr return self[key]


  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 90, in __getitem__
    return get_session_state()[key]
           ~~~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\safe_session_state.py", line 91, in __getitem__
    return self._state[key]
           ~~~~~~~~~~~^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 400, in __getitem__
    raise KeyError(_missing_key_error_message(key))
KeyError: 'st.session_state has no key "last_time". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Code\Python\chat-analyzer\Home.py", line 159, in <module>
    streamlit_analytics.start_tracking()
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit_analytics\main.py", line 276, in start_tracking
    _track_user()
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit_analytics\main.py", line 78, in _track_user
    counts["total_time_seconds"] += (now - st.session_state.last_time).total_seconds()
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 121, in __getattr__
    raise AttributeError(_missing_attr_error_message(key))
AttributeError: st.session_state has no attribute "last_time". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization

C:\Code\Python\chat-analyzer>python __init__.py

C:\Code\Python\chat-analyzer>python Home.py
2024-01-30 11:54:43.897 WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without `streamlit run`
Traceback (most recent call last):
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 398, in __getitem__
    return self._getitem(widget_id, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 443, in _getitem
    raise KeyError
KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 119, in __getattr__
    return self[key]
           ~~~~^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 90, in __getitem__
    return get_session_state()[key]
           ~~~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\safe_session_state.py", line 91, in __getitem__
    return self._state[key]
           ~~~~~~~~~~~^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state.py", line 400, in __getitem__
    raise KeyError(_missing_key_error_message(key))
KeyError: 'st.session_state has no key "last_time". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Code\Python\chat-analyzer\Home.py", line 159, in <module>
    streamlit_analytics.start_tracking()
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit_analytics\main.py", line 276, in start_tracking
    _track_user()
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit_analytics\main.py", line 78, in _track_user
    counts["total_time_seconds"] += (now - st.session_state.last_time).total_seconds()
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dan_e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\streamlit\runtime\state\session_state_proxy.py", line 121, in __getattr__
    raise AttributeError(_missing_attr_error_message(key))
AttributeError: st.session_state has no attribute "last_time". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization
aloncohen1 commented 8 months ago

Hi Since this is a streamlit app, you should run it as follows: https://docs.streamlit.io/knowledge-base/using-streamlit/how-do-i-run-my-streamlit-script

lokeshdubey2001 commented 6 months ago

hey i am getting some issue related to secret.toml file . I need tracking pass and google site code to run the app but it doesn't exist in you github repo

lokeshdubey2001 commented 6 months ago

please help bro I need your help

aloncohen1 commented 6 months ago

@lokeshdubey2001 you must create a secret.toml by yourself. this file should be located: "at ~/.streamlit/secrets.toml for macOS/Linux or %userprofile%/.streamlit/secrets.toml for Windows"

Read more here

for this app, the secret.toml should contain the following values:

hf_api_token = "your_hf_code_here"
tracking_pass = "your_tacking_pass_here"
google_site_verification_code = "your_google_site_var_here"

The only relevant value your should update is the hf_api_token see here how to create your own token