venv posit connect question

Hi-this is my first post here. So we use posit connect and I am having a hard time figuring out how to get my virtual environment for python to be accessible for python in my shiny app. In the documentation it says to CD to the project directory and create a .venv but I’m not exactly sure what the project directory is or where in opt that would be. If anyone else has successfully done this I would create appreciate the help!

Are you trying to deploy a Shiny for R app that uses reticulate or a Shiny for Python app? Are you doing this from your laptop, Posit Workbench, or somewhere else?

Apologies for not including that. I am using reticulate in my R shiny app in this case and deploying from my laptop

The article on reticulated deployments above has the advice you want to follow--try writing a manifest locally to ensure that your python environment has been captured. It should look something like this one: python-examples/reticulated-sentiment-analysis-app/manifest.json at main · sol-eng/python-examples · GitHub

Once your manifest contains that information, Connect will reconstruct a python environment for you when you deploy your app.

Hi, thanks for getting back to me. This worked perfectly for getting rdkit in my python environment. Apologies if this is an answered question already but if I wanted to install a package from say a conda or Conda-forge channel how would I do that? An example being smina which is in Conda-forge. Would it be directly in that requirements.txt file? Thanks again for all the help!

Connect uses pip (or optionally, uv) to restore Python environments, so if the package cannot be pip installed, then you will have to find some other way to include the dependency.

If your organization licenses Package Manager, you may be able to build and serve your own copy as described here from a private python repository.

Alternatively, you may be able to take the precompiled binary from sourceforge and package it in a way your application can access. There are a couple of possible approaches for this:

If you want to chat in more detail about either of these approaches, have your customer success manager set up a conversation with someone on our solutions engineering team.

Good luck!