@andreas_rc do you have any leads about heavy tweaking steps to settings? Iām happy to try from my end and debug
Yes, thatās how it worked. Since we had a common shared folder we did not need to have the ability to upload your own files.
Unfortunately nothing specific. I had several error messages and was able to get past some of them with google but in the end stopped. Iāll check out Docker + AWS to share. If you have success with .exe would be interested to see!
Nice! I tested it and it does seem to work well. However, I get a 405 error when trying to use the st.file_uploader.
I also tried to select a path as follows:
# load data
path_input_data = st.sidebar.text_input("Provide the name to the subfolder in which your csv files are "
"stored.")
if path_input_data:
excel_files = glob.glob(path_input_data + '/**/*.csv', recursive=True)
st.write(excel_files)
What I want to do is provide the complete path to the local folder in which data is stored. When creating a container I can only refer to the relative path inside of the container, which means that users cannot select their own data. Any suggestions on how to work around this? Iām probably missing something obvious here, as I am not too familiar with Docker images.
We also continue to keep in touch over email, but just to keep any other readers up to date, here is a summary of our discussion:
Thank you for getting in touch - Iām really pleased to hear you have enjoyed ContainDS Desktop!
I think the important piece of information you are missing is that the āworkspace folderā on your computer maps to the path ā/appā inside the Docker container.
So for example, on my Mac the container is running with a workspace of /Users/dan/streamlit-single and this can be accessed via /app in the containerās Streamlit code.
Here is my example folder on the Mac:
|- code.py
|- csvfiles
|- test.csv
|- testboxes.csv
My version of the Python code is at the end of this email, showing two methods of accessing the files - direct access through Python code, and then using st.file_uploader.
For the direct access method (not using st.file_uploader) it is important to understand that most of your computerās hard drive is not accessible directly by the container. That is essential for security. So the csv files should ideally be in your workspace folder (as mine are above). You could always use a symlink if you really wanted to store them elsewhere on your hard drive.
Rather than expect the user to know that /app is the location for accessing the workspace from inside the container, in my example code I just expect them to type the immediate subfolder name of ācsvfilesā and then I prepend ā/app/ā to that. In fact, if you just want to find all csv files in the workspace then you could just glob from the /app folder recursively anyway, so you donāt really need to specify the subfolder name.
For the file uploader version, Iām not too sure why you were seeing the 405 error. It seems to work for me using the streamlit-single Docker image, but I do see the 405 error using streamlit-launchpad images. Iāll take a look.
ā
import streamlit as st
import glob
from os import path
import pandas as pd
st.markdown('# Based on subfolder path')
path_input_data = st.sidebar.text_input("Provide the name to the subfolder in which your csv files are "
"stored.")
st.write("Input path:", path_input_data)
docker_search_path = path.join('/app', path_input_data)
st.write("Search path:", docker_search_path)
if path_input_data:
excel_files = glob.glob(docker_search_path + '/**/*.csv', recursive=True)
st.write(excel_files)
st.markdown('# Now try uploading')
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
if uploaded_file is not None:
st.write('Uploaded file: ', uploaded_file)
data = pd.read_csv(uploaded_file)
st.write(data)
st.write('Streamlit version: ', st.version._get_installed_streamlit_version())
Iāve updated streamlit-launchpad to work with the file_uploader now (version 0.0.6). To pick this up you might need to restart ContainDS Desktop and then create a new container from the latest āstreamlit-launchpadā in the Images tab.
@ bjornvandijkman
I have successfully created the .exe file by your procedure. But unable to run the .exe file, Itās throwing the below error.
āFailed to execute script run_streamlitā
Please help!!
# st-run-test.py
import streamlit as st
def main():
""" # do stuff here. """
st.markdown("Test this and that")
if __name__ == "__main__":
main()
# run-st-test.py
import subprocess as sp
import shlex
sp.call(shlex.split("streamlit run st-test.py"), shell=True)
I seem to successfully freeze run-st-test.py with pyinstaller (pyinstaller run-st-test.py -c) and run the exe. Will give it a try with my rather complicated streamlit project. I would guess it should work.
It also works with more complicated cases. The problem is, it only freeze run-st-test.py.
I am looking for a way to freeze st-run-test.py and anything it makes use of. The reason: I want other people to be able to run my streamlit program without explicitly sharing the source code. Is this possible?
@mikee @bjornvandijkman
This is not the solution I was hoping for, as it only makes an .exe file of the calling script. Python and streamlit still needs to be present on the executerās computer.
Thatās why Srinath and andreas are not able to run the .exe
Am I missing something or is it just not possible to create a (single) executable with pyinstaller for streamlit apps?
I have not used pyinstaller since to be honest. I have however successfully shared applications locally using containds of @danlester.
Hi Chekos,
That is actually a really brilliant solution that I could use for many challenges, not just streamlit.
Installing python or anaconda to a shared drive is easy enough. But what I do not get, is how you managed to install the extra libraries to the shared drive?
I have python on my own machine and on the shared drive now, but pip installing will just install them on my own machine. How did you get around this?
Hi all -
Iām new to Streamlit AND not familiar with deploying apps. I have started creating a Streamlit app and want to be sure I can deploy this locally before continuing to work on it.
This thread has become quite long and I donāt believe I see anywhere people have been able to do this without using some other resource. The requirements I have seem to match with those stated in the initial question here.
-
What I think I understand from the latest posts is installing python and streamlit, and other necessary libraries for the specific app (on the shared drive), makes this possible. Does that sound correct?
-
If number 1 here does work, I still need direction on what to do and what exactly I can provide to my non-techy co-workers. Can anyone help with that?
If it helps hereās what Iām doing - the simple app I am creating reads in pickle files stored locally and shows some data to the user. It then gets input from the user that is then stored back in the pickle files. This app doesnāt involve a machine learning model. Itās very simple. Iād like the user to be able to go their browser and open a link to access this OR click on a short-cut on their screen. Currently, this is set up for Windows users but I can revise the code to open the file location for mac users later. I donāt want to work on the app further until I know I can deploy what I have without the cost of subscribing to a service.
Thank you.
More questions regarding my last ones.
- Can I deploy something locally that points to data on our local drives?
- How do I deal with allowing only one user access at a time?
- I canāt access the link provided for ContainDS.
Update: Iāve installed PyInstaller to test making an executable with it. Itās in the process of creating it now. The down-side is it seems to be taking into consideration every possible package, that shouldnāt necessarily be in my environment, not only the couple packages I would list in a requirements.txt file.
To be clear, is your goal to create an executable for each person to be able to run the app (conveniently) on their own computer, with the app then having access to that userās local files? Or are you talking about everyone being able to access the app through your local network by having it run on a network computer on which the files are stored?
The latter is much simpler. When you install Python and install streamlit on some host computer, and then you streamlit run your_app.py
on that computer, the app becomes available to all computers on your local network (modulo firewall settings). As long your computer and network firewalls arenāt locked down tight, then all the computers that can āseeā the host machine will be able to access the app through that host machineās ip address. If your app useās a file_uploader
widget, then users will be able to select files from their own machines to send to the app. But if the app is using some files specified by a path within the code, it would be trying to find those files on the host machine.
Thank you @mathcatsand.
Iād like each person to be able to run the app on their own computer - however that may be. They would be accessing the same files on the shared network drive.
Iām thinking if they have are logged onto their computer and already accessing the network drives they shouldnāt have a problem with any network firewalls or be locked out. Iām not using the file_uploader widget. The code is loading the files based on the location on the network drive.
The .exe file made by PyInstaller works. Iām going to look at the subprocess mentioned above so the user doesnāt have to take the second step of opening the command prompt to enter streamlit run your_app.py
Added the code for the subprocess as shown above, like this:
# run-st-test.py
import subprocess as sp
import shlex
sp.call(shlex.split("streamlit run st-test.py"), shell=True)
The problem I have with this is if I run the code, it ends up in a loop. It keeps running the subprocess. I will read more about subprocesses.
That is expected, web apps are expected to run forever (until an error happens or somebody else kill them).
Thanks @Goyo, I understand that. I was looking for thoughts on how to get around this.
I set this piece aside for the moment but my thought is to figure out how to get this piece to run only once. Iām thinking I might be able to do this using a session state.
Note that this is unrelated to your use of subprocess
. It would be the same if you run streamlit from a console or a batch script.