Uninstalling Packages Doesn't Work

Problem description:
While trying to uninstall a package, I ran this in the shell:

poetry remove package_name

That didn’t work, so I tried removing it from the packages tab. Didn’t work either. Here’s the error it gives me for both methods:

--> poetry remove playwright
Updating dependencies
Resolving dependencies...

Package operations: 0 installs, 0 updates, 3 removals

  • Removing greenlet (3.0.1)

  CalledProcessError

  Command '['pip', 'uninstall', 'greenlet', '-y']' returned non-zero exit status 1.

  at /nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/subprocess.py:526 in run
       522│             # We don't call process.wait() as .__exit__ does that for us.
       523│             raise
       524│         retcode = process.poll()
       525│         if check and retcode:
    →  526│             raise CalledProcessError(retcode, process.args,
       527│                                      output=stdout, stderr=stderr)
       528│     return CompletedProcess(process.args, retcode, stdout, stderr)
       529│ 
       530│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['pip', 'uninstall', 'greenlet', '-y'] errored with the following return code 1
  
  Output:
  error: externally-managed-environment
  
  × This environment is externally managed
  ╰─> This command has been disabled as it tries to modify the immutable
      `/nix/store` filesystem.
      
      To use Python with Nix and nixpkgs, have a look at the online documentation:
      <https://nixos.org/manual/nixpkgs/stable/#python>.
  
  note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
  hint: See PEP 668 for the detailed specification.
  

  at /nix/store/kglgy8nffq9gpdnh517h73w3x8zcqhsn-poetry-in-venv/env/lib/python3.10/site-packages/poetry/utils/env.py:1523 in _run
      1519│                 output = ""
      1520│             else:
      1521│                 output = subprocess.check_output(cmd, stderr=stderr, env=env, **kwargs)
      1522│         except CalledProcessError as e:
    → 1523│             raise EnvCommandError(e, input=input_)
      1524│ 
      1525│         return decode(output)
      1526│ 
      1527│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

  • Removing playwright (1.40.0)

  CalledProcessError

  Command '['pip', 'uninstall', 'playwright', '-y']' returned non-zero exit status 1.

  at /nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/subprocess.py:526 in run
       522│             # We don't call process.wait() as .__exit__ does that for us.
       523│             raise
       524│         retcode = process.poll()
       525│         if check and retcode:
    →  526│             raise CalledProcessError(retcode, process.args,
       527│                                      output=stdout, stderr=stderr)
       528│     return CompletedProcess(process.args, retcode, stdout, stderr)
       529│ 
       530│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['pip', 'uninstall', 'playwright', '-y'] errored with the following return code 1
  
  Output:
  error: externally-managed-environment
  
  × This environment is externally managed
  ╰─> This command has been disabled as it tries to modify the immutable
      `/nix/store` filesystem.
      
      To use Python with Nix and nixpkgs, have a look at the online documentation:
      <https://nixos.org/manual/nixpkgs/stable/#python>.
  
  note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
  hint: See PEP 668 for the detailed specification.
  

  at /nix/store/kglgy8nffq9gpdnh517h73w3x8zcqhsn-poetry-in-venv/env/lib/python3.10/site-packages/poetry/utils/env.py:1523 in _run
      1519│                 output = ""
      1520│             else:
      1521│                 output = subprocess.check_output(cmd, stderr=stderr, env=env, **kwargs)
      1522│         except CalledProcessError as e:
    → 1523│             raise EnvCommandError(e, input=input_)
      1524│ 
      1525│         return decode(output)
      1526│ 
      1527│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

  • Removing pyee (11.0.1)

  CalledProcessError

  Command '['pip', 'uninstall', 'pyee', '-y']' returned non-zero exit status 1.

  at /nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/subprocess.py:526 in run
       522│             # We don't call process.wait() as .__exit__ does that for us.
       523│             raise
       524│         retcode = process.poll()
       525│         if check and retcode:
    →  526│             raise CalledProcessError(retcode, process.args,
       527│                                      output=stdout, stderr=stderr)
       528│     return CompletedProcess(process.args, retcode, stdout, stderr)
       529│ 
       530│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['pip', 'uninstall', 'pyee', '-y'] errored with the following return code 1
  
  Output:
  error: externally-managed-environment
  
  × This environment is externally managed
  ╰─> This command has been disabled as it tries to modify the immutable
      `/nix/store` filesystem.
      
      To use Python with Nix and nixpkgs, have a look at the online documentation:
      <https://nixos.org/manual/nixpkgs/stable/#python>.
  
  note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
  hint: See PEP 668 for the detailed specification.
  

  at /nix/store/kglgy8nffq9gpdnh517h73w3x8zcqhsn-poetry-in-venv/env/lib/python3.10/site-packages/poetry/utils/env.py:1523 in _run
      1519│                 output = ""
      1520│             else:
      1521│                 output = subprocess.check_output(cmd, stderr=stderr, env=env, **kwargs)
      1522│         except CalledProcessError as e:
    → 1523│             raise EnvCommandError(e, input=input_)
      1524│ 
      1525│         return decode(output)
      1526│ 
      1527│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

exit status 1

Expected behavior:
I can uninstall any package.

Actual behavior:
It gives me an error while trying to uninstall packages.

Steps to reproduce:
Uninstall a package, either with poetry remove or the packages tab,

Browser: Microsoft Edge
OS: Windows 11
Device (Android, iOS, NA leave blank): N/A
Desktop app version (Avatar menu->“Version”) or NA: N/A
Plan (Free, Replit Core): Replit Core

Why are you trying to uninstall pip?

I wasn’t. I think I accidentally typed that just now. Let me fix that.

EDIT: Check now. I was uninstalling playwright.

Many packages, such as moviepy, cannot be uninstalled because poetry wants to uninstall builtin packages such as setuptools (which is impossible since it is a nix package).
If any of the dependencies depend on some sort of builtin package, uninstalling will probably fail.
For a workaround, messing around with .pythonlibs and pyproject.toml, deleting stuff manually, should work.

1 Like