Creating & Deploying Shiny Apps in Python

Trevor French
Trevor French
Published in
2 min readOct 12, 2022

It’s finally here! Along with it’s announced rebranding to ‘Posit’, RStudio also released it’s alpha version of ‘Shiny for Python’. Here’s how you can get started creating and deploying Shiny apps in Python.

Set-up

The first step is going to be installing the necessary packages and creating a sample application.

  1. Install shiny
pip install shiny

2. Create starter application

shiny create app_name

3. Run your new app

shiny run --reload app_name/app.py

Successfully running each of the above commands will leave you with a sample app that looks like the following:

Python Shiny Sample App

Additional set-up resources from R Studio:

Configure

The next step is to configure your local environment in preparation for deploying your newly created application.

  1. Install rsconnect-python
pip install rsconnect-python

2. Configure rsconnect-python

rsconnect add --account [ACCOUNT] --name [NAME] --token [TOKEN] --secret [SECRET]

The variables can be retrieved by going to your shinyapps.io account, selecting your name in the top-right corner, and pressing “tokens”.

shinyapps.io profile

You will then see a screen that looks like this:

Shiny python tokens

3. Generate manifest file

rsconnect write-manifest shiny app_name/

After generating your manifest file, the file structure of your app should be as follows:

app_name/
app.py
manifest.json
requirements.txt

Deploy

Finally, you’re going to deploy your app to shinyapps.io. Your deploy command will be structured like this:

rsconnect deploy shiny /path/to/app_name --name [NAME] --title app_name

For example:

rsconnect deploy shiny /app_name --name trevorfrench --title app_name

Additional configuration & deployment resources from R Studio:

--

--

Trevor French
Trevor French

I am an Analytics Manager in the Crypto industry with an M.S. in Data Analytics and a B.S. in Business Analytics. I talk about R, Python, and Data Science.