Problems with streamlit run after creating executable from pyinstaller

I am fairly new to streamlt functionality, and I have been following the using streamlit to create an executable and running it locally threads. Currently, my team and I are working on an application powered by a Large Language Model (LLM) using Streamlit. Our goal is to create an executable where the code is protected and unreadable to others. To achieve this, I’ve outlined a three-step process:

  1. Code Obfuscation: Utilizing PyArmor to obfuscate the code.
  2. Executable Creation: Using PyInstaller to turn the obfuscated code into an executable.
  3. Docker Image Creation: Packaging the entire executable within a Docker image.

I’ve successfully created the executable by modifying the .spec file, which resulted in a ‘streamlit_main’ executable file. However, I’ve encountered a significant challenge at this stage. When I attempt to run the executable using ./streamlit_main, I receive an error:
WARNING streamlit:
Warning: to view this Streamlit app on a browser, run it with the following

streamlit run ./streamlit_main_query [ARGUMENTS]

2024-01-22 22:24:05.392 WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without streamlit run.

Yet, executing this command leads to another error stating that streamlit run can only operate with Python files, the error I see is:
Error: Streamlit requires raw Python (.py) files, but the provided file has no extension.

I’m stuck because I can’t add any source code or Python files to this setup. Does anyone know a better way to do this? Any advice or tips would be really helpful.

I am facing exact same issue, has anyone figured out a solution to this issue?

Hello @NitikGupta,

Since you cannot run the binary directly with streamlit run , maybe consider creating a Python bootstrap script that executes the binary.

  1. Create a Python Wrapper (
import subprocess['./streamlit_main'])
  1. Use PyInstaller to compile into an executable
  2. Instead of running streamlit run ./streamlit_main , you’ll execute the wrapper script’s binary, which in turn launches your Streamlit app contained within the streamlit_main binary.