'Opening Streamlit using bat file results in File Not Fund Error
Trying to open a app using .bat file so that other users don't have to use a terminal to open the app. The bat file has the contents as below
set root=C:\Users\***\Anaconda3
call %root%\Scripts\activate.bat
call conda activate dsatprediction
call streamlit run "C:\Users\***\PycharmProjects\dsatpred\app.py"
When the file is run, it results in
The same app runs using the command streamlit run app.py on terminal.
Any guidance is appreciated
Solution 1:[1]
I don't know what causes the error you see, but my batch file is done differently, maybe it can help you. I have gotten this code to run my files:
call C:\[anaconda_path_goes_here]\envs\[env_name_goes_here]\Scripts\activate.bat
C:\[anaconda_path_goes_here]\envs\[env_name_goes_here]\Scripts\streamlit.exe run [path_to_streamlit_file]\[name_of_streamlit_file].py
I install conda in my env and run the activate command directly in that env. Maybe it makes a difference. On the other hand, my streamlit apps don't open an files from the disk, so it may not solve your problem.
Solution 2:[2]
I managed to make mine work this way :
@ECHO OFF
set root=C:\Anaconda3
call %root%\Scripts\activate.bat
cd [PATH_TO_YOUR_STREAMLIT_APP_FOLDER]
pip install -r requirements.txt
call streamlit run app.py
Be sure to have Anaconda installed. Give that path to the root variable. Activate that conda environment. The path to your streamlit app is only to the folder, finished by a “” and does not include your .py script. This does not need to be between " " or between . Just copy-paste the path. I added the pip install -r requirements to force the update of the python libraries needed to run my app. This is not mandatory, but just makes your life easier. Finally, I simply call my app.
Your file can be located anywhere and the app runs fine.
Solution 3:[3]
@ECHO OFF
call "C:\[full path the app folder]\venv\scripts\activate.bat"
cd C:\[full path to app folder]
streamlit run app.py
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nick W |
Solution 2 | Hibernatus50 |
Solution 3 | James Bullock |