Skip to content
Latchkey

Python venv "activate: No such file" in Non-Bash Shells (sh/fish/PowerShell)

venv ships a separate activation script per shell. In CI the default shell is often sh/dash (not bash), where source doesn’t exist - or you sourced activate when the shell needs activate.fish/Activate.ps1.

What this error means

A CI step fails with source: not found, .: activate: No such file or directory, or activation that silently does nothing so later commands use the system Python. It "works" interactively in bash but not in the CI shell.

CI log
/bin/sh: 1: source: not found
# or, fish
fish: Unknown command: source ... use '.' instead? - and activate is bash-syntax
# or, PowerShell
. : The term 'activate' is not recognized ...

Common causes

CI shell is sh/dash, not bash

source is a bash builtin; POSIX sh/dash only has .. A step that runs source .venv/bin/activate under sh fails immediately.

Wrong activate script for the shell

venv provides activate (bash/zsh), activate.fish, activate.csh, and Activate.ps1. Sourcing the bash one in fish/csh/PowerShell breaks on syntax.

How to fix it

Use the POSIX dot, or pin bash

Under sh/dash use . instead of source, or declare bash as the step shell.

Terminal / ci.yml
# POSIX-portable
. .venv/bin/activate
# or pin the shell (GitHub Actions)
# - run: source .venv/bin/activate
#   shell: bash

Source the shell-specific script

Terminal
# fish
source .venv/bin/activate.fish
# PowerShell
.\.venv\Scripts\Activate.ps1

Skip activation entirely

Avoid activation problems by calling the venv interpreter by path, or adding its bin dir to PATH once.

Terminal
.venv/bin/python -m pytest
# or
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"

How to prevent it

  • Don’t use source in steps that may run under sh/dash - use . or pin shell: bash.
  • Match the activate script to the shell (fish/csh/PowerShell variants).
  • Prefer calling .venv/bin/python or persisting the venv bin to PATH over activation.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →