Pulumi up cannot import the pulumi package in a Python project
Your error
It looks like the Pulumi SDK has not been installed. Have you run pip install?1 more line it can showFix it fast
Most common cause, 1 of 2Pulumi.yaml points at a venv that does not contain pulumi
Check that requirements.txt lists pulumi and your provider packages, then install them into that venv. pulumi install does the same for the whole project.
grep -i '^pulumi' requirements.txt
venv/bin/python -m pip install -r requirements.txt
# or let the CLI do it
pulumi installShort answer
"It looks like the Pulumi SDK has not been installed" means the Python that Pulumi started cannot import pulumi. With virtualenv set in Pulumi.yaml, Pulumi uses that folder, not your conda or global Python. Without it, Pulumi runs python3 from PATH. Install requirements.txt into the venv Pulumi uses, or activate the right env first (Pulumi 3.277).
Which cause do you have?
Read the runtime block of Pulumi.yaml. A virtualenv line means Pulumi ignores whatever env your shell has active and uses that folder (cause 1). No virtualenv line means Pulumi takes python3 from PATH, so the active env decides (cause 2).
grep -A5 '^runtime' Pulumi.yaml
which python3Then find the line you see in this list and open its fix:
- 1Pulumi.yaml points at a venv that does not contain pulumi
Pulumi.yaml has virtualenv: venv, and venv/bin/python -c 'import pulumi' fails while your conda or global Python imports it fine - 2No virtualenv option, and the shell running pulumi has the wrong Python
Pulumi.yaml has only runtime: python, and which python3 points outside the conda or venv where you installed pulumi
What does the error look like?
It looks like the Pulumi SDK has not been installed. Have you run pip install?If you are running in a virtualenv, you must run pip install -r requirements.txt from inside the virtualenv.
Cause 1 of 2
Pulumi.yaml points at a venv that does not contain pulumi
You seePulumi.yaml has virtualenv: venv, and venv/bin/python -c 'import pulumi' fails while your conda or global Python imports it fine
Check
The SDK-not-installed message appears here because the pip toolchain activates the folder named by the virtualenv option and runs your program with its Python. Packages you added to conda, Homebrew Python or the system interpreter are invisible inside it. Pulumi only fills the folder by itself when it is missing or empty.
venv/bin/python -c 'import pulumi, sys; print(sys.prefix)'Fix
Check that requirements.txt lists pulumi and your provider packages, then install them into that venv. pulumi install does the same for the whole project. If you would rather keep using a conda env, delete the venv folder and remove the virtualenv line instead (see cause 2).
grep -i '^pulumi' requirements.txt
venv/bin/python -m pip install -r requirements.txt
# or let the CLI do it
pulumi installVerify
The import prints the venv's path, and pulumi preview starts reading your program instead of stopping.
pulumi previewConfirmed by pulumi.com
Cause 2 of 2
No virtualenv option, and the shell running pulumi has the wrong Python
You seePulumi.yaml has only runtime: python, and which python3 points outside the conda or venv where you installed pulumi
Check
When Pulumi.yaml names no virtualenv, the language host runs PULUMI_PYTHON_CMD if it is set, else the first python3 (then python) on PATH; Windows tries python first. A conda env that is not active in that shell leaves an interpreter without the SDK, so the import fails.
python3 -c 'import pulumi, sys; print(sys.executable)'Fix
Pulumi's guide for self-managed environments says to run every pulumi command from an activated environment. Activate the env in the same terminal or CI step, then run pulumi up. To pin the interpreter by name, export PULUMI_PYTHON_CMD.
conda activate infra
python3 -m pip install -r requirements.txt
pulumi upVerify
sys.executable now lives inside the conda env, and pulumi up shows the preview of changes.
python3 -c 'import sys; print(sys.executable)' && pulumi upConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Commit Pulumi.yaml with an explicit toolchain and virtualenv choice, so every machine and CI runner picks the same interpreter.
- Start CI jobs with pulumi install before pulumi preview or pulumi up, so a fresh runner never meets an empty environment.
- Keep pulumi in requirements.txt or pyproject.toml next to the provider packages, instead of installing it by hand on one laptop.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: stegnor.com, Menulo, ShopGo.