Python Best way to fix "externally managed environment" error?

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
AI Thread Summary
The discussion focuses on methods to bypass the "externally managed environment" error encountered when installing Python packages globally on Linux. It highlights that recent Linux distributions are adhering to PEP-668 standards, which prevent pip packages from being installed globally by default to avoid conflicts with system package managers. The first method, which involves deleting the EXTERNALLY-MANAGED file, is cautioned against as it may lead to further issues. The third method, using "pipx," is presented as a viable workaround. Pipx automates the creation of virtual environments for each package, allowing users to avoid the error while managing packages effectively. While pipx is seen as a safe solution for installing utilities that aren't project-specific, it's noted that each project should ideally maintain its own virtual environment to prevent conflicts. Overall, pipx is recognized for its utility in managing Python packages without interfering with system installations.
Swamp Thing
Insights Author
Messages
1,028
Reaction score
763
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
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top