Examples of using Python with Posit Connect
Posit Connect is a publishing platform for the work your team creates in R and Python. This repository contains examples of Python content you can deploy to Connect, including:
Reticulate allows you to call Python from within an R session. This enables you to use models built in Python to power Shiny apps, visualize pandas dataframes with ggplot2, and much more.
You can deploy examples from this repo to your Connect server via git-backed deployment, or clone the repository and deploy examples from their manifests with the rsconnect
CLI.
If you want to explore an example more closely before deploying it:
$ cd flask-sentiment-analysis-api
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install -U pip setuptools wheel
$ python -m pip install -r requirements.txt
For reticulated content, set the RETICULATE_PYTHON
environment variable to point to your virtual environment, by placing an .Renviron
file in the folder containing the following:
RETICULATE_PYTHON=.venv/bin/python
Overview:
rsconnect add \
--api-key <MY-API-KEY> \
--server <https://connect.example.org:3939> \
--name <SERVER-NICKNAME>
rsconnect deploy api . -n <SERVER-NICKNAME>