question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pip uninstall` fails when called in the package's source dir

See original GitHub issue

Environment

  • pip version: 19.1.1
  • Python version: 3.6.8
  • OS: macOS

Description

I installed a local package, spam, using python3 -m pip install --user .. If I try to uninstall my package when the package folder is in the current directory, I get the following:

$ pwd
/Users/me/spam
$ ls
README.md  setup.cfg  setup.py  test  tox.ini  spam
$ python3 -m pip uninstall --verbose spam
Not sure how to uninstall: spam 0.0.1 - Check: /Users/me/spam  # this line only shown with --verbose flag
Can't uninstall 'spam'. No files were found to uninstall.

The uninstall completes successfully when I run it from a different directory:

$ cd \tmp && python3 -m pip uninstall --verbose spam
# successfully uninstalls...

Expected behavior I did not expect uninstall to be sensitive to the contents of the local directory. If this is the expected behavior for technical reasons, I would change the stderr message Can't uninstall 'spam'. No files were found to uninstall. to be more helpful in indicating that the failure could be because there is a local folder with the target package’s name.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
reynoldsnlpcommented, Jul 14, 2019

@pfmoore I think your edited message is definitely an improvement (and would have saved me some time), but I would go even further. What about something more instructive, like Can't uninstall 'spam' (in current directory). No files were found to uninstall.\nTo uninstall 'spam' from the system library, run the same command from a directory without a 'spam' directory. (and change system library if there is a more precise term). Is that too verbose?

It seems like the only time someone would ever bump up against this message is if they were in a similar situation to me. I may be wrong, but uninstalling from the current directory like cd path/to/site-packages && python3 -m pip uninstall spam seems like a marginal use case, and if someone knows enough to be doing that, then a message tuned for mouth-breathers like me will not confuse them.

It seems that most users just assume – like I did 😉 – that uninstall is going to magically go find the package in the system library.

1reaction
piotr-dobrogostcommented, Apr 9, 2021

With pip list I get also the package in the current working directory, which makes sense because it is available there.

After change in https://github.com/pypa/pip/pull/7955 you should not get this package unless your PYTHONPATH includes current working directory.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling `pip uninstall` from the source folder where `setup.py ...
In the output of the pip show -f pybliometrics command, we can read: Files: Cannot locate RECORD or installed-files.txt.
Read more >
How to Uninstall Python Packages - ActiveState
Open a command window by entering 'cmd' in the Search Box of the Task bar; Press Ctrl+Shift+Enter to gain Administration (Admin) privileges; pip...
Read more >
Changelog - pip documentation v22.3.1
Implement a top-level pip download command and deprecate pip install --download . When uninstalling, look for the case of paths containing symlinked directories...
Read more >
Package installation issues | PyCharm Documentation
If you get an identical error message, then the problem is not in the IDE and you should ... source <venv path>/bin/activate pip...
Read more >
Pip cannot uninstall <package> error solved in Python
The Python error "Cannot uninstall [package]" occurs when we install a package with the operating system's package manager and try to update ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found