Skip to content

Publishing from the Command Line#

Posit 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 Posit 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 Posit 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. Posit 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 Posit Connect will install to run your content. Using the same requirements.txt file across multiple deployments also allows Posit 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#

Posit 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 Posit 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 deploying an API or application, 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 Posit 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 Posit 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.

Target Image#


This section describes a feature that is currently in beta. If you are not sure if this applies to you, please speak with your administrator.

If your Posit Connect installation uses off-host content execution with Kubernetes, Connect will automatically select an appropriate image to use when building or running your content. However, you can also specify a different image if you prefer, by providing the image argument when writing a manifest or deploying:

rsconnect deploy api --image "" ...

rsconnect write-manifest api --image "" ...

You may only use an image that has been configured by your administrator. You can see a list of available images by logging in to Posit Connect and clicking the Documentation button at the top of the page.

If the image you select does not contain an appropriate Python version for the content you are deploying, the deployment will fail.

At any time, you may redeploy content without specifying an image (or write a manifest without specifying an image, and deploy the manifest) to go back to allowing Posit Connect to choose an image automatically.


The following subcommands do not support the --image argument:

rsconnect deploy html
rsconnect deploy manifest
rsconnect deploy other-content

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 Posit Connect dashboard to activate the previous version and remove the erroneous one.