posts icon indicating copy to clipboard operation
posts copied to clipboard

Issue in post: "Converting Streamlit application to exe file" - OSError: could not get source code

Open indranildchandra opened this issue 1 year ago • 1 comments

I am running into following error while trying to run the .exe file. Any ideas on how this can be fixed? Python==3.10.13 streamlit==1.30.0 pyinstaller==6.3.0

` --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 86, in File "streamlit/runtime/caching/cache_resource_api.py", line 254, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_resource_api.py", line 435, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 174, in File "streamlit/runtime/caching/cache_resource_api.py", line 254, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_resource_api.py", line 435, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 216, in File "streamlit/runtime/caching/cache_resource_api.py", line 254, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_resource_api.py", line 435, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) 2024-02-02 04:52:50.639 WARNING streamlit.runtime.caching.cache_data_api: No runtime found, using MemoryCacheStorageManager --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 378, in File "streamlit/runtime/caching/cache_data_api.py", line 374, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_data_api.py", line 575, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 395, in File "streamlit/runtime/caching/cache_resource_api.py", line 254, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_resource_api.py", line 435, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) --- Logging error --- Traceback (most recent call last): File "streamlit/runtime/caching/cache_utils.py", line 443, in _make_function_key File "inspect.py", line 1139, in getsource File "inspect.py", line 1121, in getsourcelines File "inspect.py", line 958, in findsource OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "logging/init.py", line 1100, in emit File "logging/init.py", line 943, in format File "logging/init.py", line 678, in format File "logging/init.py", line 368, in getMessage TypeError: not all arguments converted during string formatting Call stack: File "upstox-assistant.py", line 399, in File "streamlit/runtime/caching/cache_resource_api.py", line 254, in call File "streamlit/runtime/metrics_util.py", line 396, in wrapped_func File "streamlit/runtime/caching/cache_resource_api.py", line 435, in _decorator File "streamlit/runtime/caching/cache_utils.py", line 203, in make_cached_func_wrapper File "streamlit/runtime/caching/cache_utils.py", line 224, in init File "streamlit/runtime/caching/cache_utils.py", line 445, in _make_function_key File "logging/init.py", line 1465, in debug File "logging/init.py", line 1624, in _log File "logging/init.py", line 1634, in handle File "logging/init.py", line 1696, in callHandlers File "logging/init.py", line 968, in handle File "logging/init.py", line 1108, in emit Message: "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}" Arguments: (OSError('could not get source code'),) 2024-02-02 04:52:50.640 DEBUG streamlit.runtime.caching.cache_resource_api: Creating new ResourceCache (key=4741a7ee8f1d95c09918e4a7aa6f6e51) 2024-02-02 04:52:50.640 DEBUG streamlit.runtime.caching.cache_utils: Cache key: d41d8cd98f00b204e9800998ecf8427e 2024-02-02 04:52:50.640 WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without streamlit run 2024-02-02 04:52:50.640 DEBUG streamlit.runtime.caching.cache_resource_api: Creating new ResourceCache (key=31a41423133377fc5deb1f050015b164) 2024-02-02 04:52:50.641 DEBUG streamlit.runtime.caching.cache_utils: Cache key: a60628542634f5959daec6d908c6f29a messages initialised in session_state object Traceback (most recent call last): File "streamlit/runtime/state/session_state.py", line 398, in getitem File "streamlit/runtime/state/session_state.py", line 443, in _getitem KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "streamlit/runtime/state/session_state_proxy.py", line 119, in getattr File "streamlit/runtime/state/session_state_proxy.py", line 90, in getitem File "streamlit/runtime/state/safe_session_state.py", line 91, in getitem File "streamlit/runtime/state/session_state.py", line 400, in getitem KeyError: 'st.session_state has no key "messages". 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 "upstox-assistant.py", line 516, in File "streamlit/runtime/state/session_state_proxy.py", line 121, in getattr AttributeError: st.session_state has no attribute "messages". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization [77870] Failed to execute script 'upstox-assistant' due to unhandled exception!

Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

[Process completed] `

indranildchandra avatar Feb 02 '24 04:02 indranildchandra

Im same,How to deal with it

ujnxs123 avatar Mar 28 '24 15:03 ujnxs123