Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
reynoldsnlp opened this issue Jul 12, 2019 · 5 comments
Open

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

reynoldsnlp opened this issue Jul 12, 2019 · 5 comments
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality UX User experience related

Comments

@reynoldsnlp
Copy link

reynoldsnlp commented Jul 12, 2019

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.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jul 12, 2019
@pfmoore
Copy link
Member

pfmoore commented Jul 13, 2019

Maybe amend the error in this case to say Can't uninstall 'spam' (found in current directory). No files were found to uninstall.?

@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Jul 13, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Jul 13, 2019
@pradyunsg pradyunsg added this to the Print Better Error Messages milestone Jul 13, 2019
@reynoldsnlp
Copy link
Author

@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.

@nlhkabu nlhkabu added C: error messages Improving error messages UX User experience related labels Jul 28, 2020
@nlhkabu
Copy link
Member

nlhkabu commented Jul 28, 2020

Maybe 'your computer' would be better than 'system library'?

Iteration on your suggestion @reynoldsnlp :

Can't uninstall 'spam' (in the current directory). No files were found to uninstall.\nTo uninstall 'spam' from your computer, run the same command from a directory that does not contain a 'spam' directory.

Is it clearer?

@nlhkabu nlhkabu removed this from the Print Better Error Messages milestone Jul 29, 2020
@hoba87
Copy link

hoba87 commented Apr 9, 2021

I have an issue related to this one. With pip list I get also the package in the current working directory, which makes sense because it is available there. However to make clear that the version of the current working directory is recognized a comment in the output of pip list would be helpful.

@piotr-dobrogost
Copy link

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

After change in #7955 you should not get this package unless your PYTHONPATH includes current working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality UX User experience related
Projects
None yet
Development

No branches or pull requests

6 participants