Best way to fix "externally managed environment" error?

  • Python
  • Thread starter Swamp Thing
  • Start date
  • #1
Swamp Thing
Insights Author
908
572
This page gives three ways to bypass the "externally managed environment" error when trying to install python packages globally.
https://www.makeuseof.com/fix-pip-error-externally-managed-environment-linux/

But it also says,
The latest versions of all Linux distributions are adopting the standards defined in PEP-668. These changes ensure that pip packages will not be installed in a global context by default.

This was implemented in an attempt to avoid conflict between the distribution's package manager and Python package management tools.

So it would seem that the first method (delete the EXTERNALLY-MANAGED file) may create more problems than it solves.

But how about the third method - installing and using "pipx" ? Are there any pitfalls here, or does it take care of the package management conflicts?

=======================
Edit:
Sorry, just noticed that the same page does say this:
It automates steps like creating virtual environments for each package and creating symbolic links to the packages in the .local/bin folder so you can call each package from the shell at all times.

Using pipx to install packages helps you avoid the "externally-managed-environment" error as it installs packages in virtual environments.

This suggests that pipx should be a safe and trouble free solution.

But I can't delete a new post, and anyway if someone has used pipx they might care to weigh in and share how well it actually works.
 
Technology news on Phys.org
  • #2
Swamp Thing said:
This suggests that pipx should be a safe and trouble free solution.
It's actually not a solution to be exact, but a workaround. Virtual environments were not really made to be used like that. Each project should anyway have its own venv or Poetry environment to avoid clashes with any other project, similar to the way we use Gradle. But we cannot forget that in Linux distros, there are many utilities that come in the form of a python package and have to be installed using pip. These utilities are not supposed to be for a project, e.g. a markdown editor. So in those cases, the concept that pipx uses is good, IMO. Avoid the clash with system packages, but still be able to download and use utilities.
 

Similar threads

  • Programming and Computer Science
Replies
13
Views
3K
  • STEM Academic Advising
Replies
13
Views
2K
  • Other Physics Topics
Replies
11
Views
3K
  • Atomic and Condensed Matter
Replies
4
Views
6K
Replies
3
Views
3K
Back
Top