Skip to content

Publishing from the Command Line#

RStudio Connect supports the deployment of Jupyter notebooks, Python APIs (such as those based on Flask or FastAPI) and apps (such as Dash, Streamlit, and Bokeh apps).

Content types not directly supported by the CLI may also be deployed if they include a prepared manifest.json file. See "Deploying R or Other Content" for details.


You must configure your RStudio Connect account before attempting to publish using rsconnect-python. See the Connecting - Command Line chapter for information on configuring your Connect account.

Using rsconnect-python#

Use the rsconnect deploy command to deploy content to RStudio Connect. See the content-type specific documentation for details on the deployment commands and options available for various content types:

Package Dependencies#

If a requirements.txt file exists in the source directory, it will be included in the deployment bundle. It must specify the package dependencies needed to execute your Python code. RStudio Connect will reconstruct the Python environment using the specified package list. Using a requirements.txt file gives you the most control over the packages that RStudio Connect will install to run your content. Using the same requirements.txt file across multiple deployments also allows RStudio Connect to reuse the corresponding Python virtual environments, making deployments faster.

If there is no requirements.txt file or the --force-generate option is specified, the package dependencies will be determined from the current Python environment, or from an alternative Python executable specified via the --python option or via the RETICULATE_PYTHON environment variable. For example:

rsconnect deploy api --python /path/to/python my-api/

You can see the packages list that will be included by running pip list --format=freeze yourself. Ensure that you use the same Python that you use to run your code. For example, if you have created a virtual environment for your project, activate the environment or specify the full path to the Python interpreter:

/path/to/python -m pip list --format=freeze

Python Version Matching#

RStudio Connect requires matching <MAJOR.MINOR> versions of Python. For example, a server with only Python 3.8 installed will fail to deploy content created with Python 3.7. Your administrator may also enable exact Python version matching which will be stricter and require matching major, minor, and patch versions. For more information see the RStudio Connect Admin Guide chapter titled Python Version Matching.

Deployment Options#

These options apply to any type of content deployment.


The title of the deployed content is, by default, derived from the filename. For example, if you deploy my-notebook.ipynb, the title will be my-notebook. To change this, use the --title option:

rsconnect deploy notebook --title "My Notebook" my-notebook.ipynb

When using rsconnect deploy api, rsconnect deploy fastapi, rsconnect deploy dash, rsconnect deploy streamlit, or rsconnect deploy bokeh, the title is derived from the directory containing the API or application.

When using rsconnect deploy manifest, the title is derived from the primary filename referenced in the manifest.

Environment Variables#

You can set environment variables during deployment. Their names and values will be passed to RStudio Connect during deployment so you can use them in your code.

For example, if notebook.ipynb contains


You can set the value of MYVAR that will be set when your code runs in RStudio Connect using the -E/--environment option:

rsconnect deploy notebook --environment MYVAR='hello world' notebook.ipynb

To avoid exposing sensitive values on the command line, you can specify a variable without a value. In this case, it will use the value from the environment in which rsconnect-python is running:

export SECRET_KEY=12345

rsconnect deploy notebook --environment SECRET_KEY notebook.ipynb

If you specify environment variables when updating an existing deployment, new values will be set for the variables you provided. Other variables will remain unchanged. If you don't specify any variables, all of the existing variables will remain unchanged.

Environment variables are set on the content item before the content bundle is uploaded and deployed. If the deployment fails, the new environment variables will still take effect.

Updating a Deployment#

If you deploy a file again to the same server, rsconnect will update the previous deployment. This means that you can keep running rsconnect deploy notebook my-notebook.ipynb as you develop new versions of your notebook. The same applies to other Python content types.

Forcing a New Deployment#

To bypass this behavior and force a new deployment, use the --new option:

rsconnect deploy dash --new my-app/

Updating a Different Deployment#

If you want to update an existing deployment but don't have the saved deployment data, you can provide the app's numeric ID or GUID on the command line:

rsconnect deploy notebook --app-id 123456 my-notebook.ipynb

You must be the owner of the target deployment, or a collaborator with permission to change the content. The type of content (static notebook, notebook with source code, API, or application) must match the existing deployment.


There is no confirmation required to update a deployment. If you do so accidentally, use the "Source Versions" dialog in the RStudio Connect dashboard to activate the previous version and remove the erroneous one.