Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9 (pip 25)
pip freeze lists installed Python packages. For packages installed in editable mode from a Mercurial repository (pip install -e hg+…), pip runs the hg command to find the repository address. Permission denied: 'hg' means that command is missing or cannot be run.
Fixes
- Install Mercurial:
dnf install mercurial(AlmaLinux/Rocky, EPEL) orapt install mercurial(Ubuntu/Debian), orpip install mercurialinside your virtual environment. - Leave editable packages out:
pip freeze --exclude-editable. - List plain name==version lines without looking at repositories:
pip list --format=freeze. - If
hgexists but is not executable, check the file:ls -l $(which hg).
Avoid it in the future
- Work inside a virtual environment per project (
python3 -m venv venv), so pip never touches system packages. - For deployments, install from released packages or Git tags instead of editable checkouts, and record versions in
requirements.txt.
Check your pip
python3 -m pip --version # which pip and which Python it belongs to python3 -m pip install --upgrade pip # inside a virtual environment
Running pip as python3 -m pip makes sure you use the pip of the Python you expect.