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:
Code Obfuscation: Utilizing PyArmor to obfuscate the code.
Executable Creation: Using PyInstaller to turn the obfuscated code into an executable.
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
command:
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?
System==macOS-14.0-23A344
Python==3.10.13
streamlit==1.30.0
pyinstaller==6.3.0
Use PyInstaller to compile wrapper.py into an executable
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.
Hi @sahirmaharaj , I have created my main.exe file, and ran into a similar issue to OP. I tried your method to create a wrapper file with the following
I created a wrapper.exe using pyinstaller and upon clicking it, I get file error and it is unable to locate my file (I’m assuming main.exe).
When I do streamlit run wrapper.py, it opens my local host but get this error in my terminal and my app doesn’t show in the local host:
Warning: to view this Streamlit app on a browser, run it with the following
command:
streamlit run dist\main.exe [ARGUMENTS]
WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without `streamlit run`
Did I misunderstand your instructions, or perhaps I did something wrong? Thank you.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.