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) or apt install mercurial (Ubuntu/Debian), or pip install mercurial inside 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 hg exists 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.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket