externally-managed-environment error on debian 12 — FIXED

This is the error message I get when I try to install the Python PowerLine extensions on Debian 12. I’ve searched quite a bit, looking for the most currently dated posts and errors. I finally found out what was happening when I searched for “python externally-managed-environment.” That led me to reading Python Enhancement Proposal (PEP) 668, Marking Python base environments as “externally managed.” Which after much reading of bloviating text I found out that;

  • if the main Python directory, which can be identified by executing sysconfig.get_path("stdlib", sysconfig.get_default_scheme()),
  • which in Debian 12’s case returns /usr/lib/python3.11,
  • contains an empty file named EXTERNALLY-MANAGED,
  • then you’ll find it impossible to install any package into the distribution’s Python dist-packages directory, which in all cases for Python 3 is /usr/lib/python3/dist-packages

Marvelous. Once I removed the EXTERNALLY-MANAGED empty file I could indeed use pip to install packages. With powerline-status finally installed my shell prompt is as I like it and when I run vim, it’s status line is as I like it as well:

This is one of my stranger problems solved. I don’t know why Python 3 in Debian 12 is shipped this way, but it’s wrong. The question I have: is this a bug that needs to be reported, or is this considered a feature? This won’t be the first time devs have taken a holier-than-thou attitude towards end users. Consider systemd, for example.

debian 12

Debian 12/Bookworm hit a hard freeze before a final release three days ago. I downloaded an ISO, installed it as a KVM/QEMU virtual machine via Virtual Machine Manager 4, using my modest Linux Mint 21.1 system as a host system.

As you can see via neofetch, Debian 12 beta is running with the 6.1 version of the Linux kernel. I was pleasantly surprised when I saw this, and the use of this kernel may help explain how well it works as a VM. Other little items I noticed:

  • The Papirus icons are now part of the Debian repos. I was able to install those icons, and then select them, using apt and the regular settings app without having to install anything extra. I much prefer this icon set over just about any other. I’ve got it installed on my Linux Mint system, and I install it, along with the Cinnamon desktop, on every other distro I work with.
  • Python is 3.11.2. This is the latest release of the 3.11 series, which is the highest current release.
  • gcc/g++ is version 12.2. This is the highest current release.
  • git is version 2.39.2. The highest current release is 2.40.0. I won’t quibble about the difference.

The only problem I’ve encountered so far is installing PowerLine. As you can see I did install it, but in order to do that I had to create a Python virtual environment, then install the Python package powerline-status inside that virtual environment. I modified my login environment to automatically activate that environment, at which point everything works, both on the shell as well as in vim. Since this is a beta version I’m going to assume that it might get fixed before final release, or possibly soon after.

If I had to use one word to describe this upcoming release, it would be “polished.” I’ve finally come around to the Debian way of the Linux world, having gotten here via Ubuntu and Linux Mint, especially LMDE 5. I like all the updated tools that Debian 12 is bringing to the party. Linux Mint is unfortunately tied to the Ubuntu 22.04 LTS release train. I would hope that LMDE will step up to Debian 12. If it does, that means that LMDE will actually be ahead of Linux Mint, at least in the near future.