This guide will walk you through setting up and running the Shiny app using Python, based on the structure of your directory.
-
Python 3.7+: Ensure you have Python installed. You can check this by running:
python --version
If you don’t have it installed, download Python here.
-
Shiny for Python: You will need to install
shiny
, which is Posit’s package for Python. -
Virtual Environment (optional but recommended): Using a virtual environment is a good practice to isolate dependencies.
First, make sure you are in the directory containing the app files. If you need to clone a GitHub repository, use:
git clone <repository-url>
cd <repository-folder>
To avoid dependency conflicts, set up a virtual environment in the directory.
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
Install shiny
and other necessary dependencies specified in the requirements.txt
file.
-
Install
shiny
:pip install shiny
-
Install the other dependencies:
pip install -r requirements.txt
Once all dependencies are installed, you can run the Shiny app.
-
Run the app:
shiny run --reload app.py
The
--reload
option allows for automatic reloading of the app if you make any code changes. -
After running the command, you should see output like:
Listening on http://127.0.0.1:8000
-
Open the provided URL (
http://127.0.0.1:8000
) in your browser to access the Shiny app.
- Dummy Data: The file
dummy_data_for_practice.csv
is included for you to test the app’s functionality with dummy data. Please free to use your own data! - VS Code Configuration: If you use VS Code, you may want to install the
Shiny for Python
extension, which will help you run the app and display the content in an in-window browser.