Hi. I’m new to pulumi and I’m trying to get the py...
# python
Hi. I’m new to pulumi and I’m trying to get the python aws quickstart (https://www.pulumi.com/docs/get-started/aws/) example working using the github actions docs (https://www.pulumi.com/docs/guides/continuous-delivery/github-actions/) but I’m getting an error
error: "/github/workspace/venv" doesn't appear to be a virtual environment
. Can anyone here tell me how to activate my venv in the
block please? Thanks!
Hi Adrian, As of the most recent version of Pulumi (v2.4.0), when you create a new Pulumi Python program with
pulumi new
creates a lightweight virtual environment in a
directory, runs
venv\bin\pip install -r requirements.txt
to install dependencies in the virtual environment, and sets the
virtualenv: venv
option in
which tells the CLI to use that virtual environment when subsequent commands (like
pulumi up
) are run. In prior versions, you’d have to do this manually and ensure you’d run
pulumi up
from an activated shell. By default, a
file is generated for the project with an entry that excludes the
dir from Git, so by default the
dir won’t be included in any commits. I’m guessing you’re seeing the error because you have
virtualenv: venv
set in
but no actual
directory in the repo? We should consider improving the Pulumi GitHub Action to take the new
option in
into account, creating the virtual environment (if it doesn’t exist) and installing dependencies into it automatically. I’ve opened https://github.com/pulumi/pulumi/issues/4871 to track this. In the meantime, it’d probably be easiest to simply remove the
virtualenv: venv
option from
. This does mean when developing the program locally on your machine you’ll need to manage a virtual environment yourself (if you don’t want to be installing dependencies globally on your machine). On macOS/Linux you can do this via:
python3 -m venv venv
, activate it by using
source venv/bin/activate
, and then install dependencies into it via
pip install -r requirements.txt
. Be sure to run
pulumi preview
pulumi up
from the activated shell. Or use a tool like Pipenv to create/manage the virtual environment.