Pip: 在包的源目录中调用 `pip uninstall` 失败

创建于 2019-07-12  ·  3评论  ·  资料来源: pypa/pip

环境

  • 点子版本:19.1.1
  • Python版本:3.6.8
  • 操作系统:macOS

描述

我使用python3 -m pip install --user .安装了一个本地软件包spam #$ 。 如果我在包文件夹位于当前目录时尝试卸载我的包,我会得到以下信息:

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

当我从不同的目录运行它时,卸载成功完成:

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

预期行为
没想到uninstall会对本地目录的内容敏感。 如果这是出于技术原因的预期行为,我将更改stderr消息Can't uninstall 'spam'. No files were found to uninstall.以更有助于指示失败可能是因为存在具有目标包名称的本地文件夹。

UX UX- error messages enhancement

最有用的评论

@pfmoore我认为您编辑的消息绝对是一种改进(并且会节省我一些时间),但我会走得更远。 更有指导意义的东西怎么样,比如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. (如果有更精确的术语,请更改system library )。 是不是太啰嗦了?

似乎有人会遇到这条消息的唯一一次是他们是否处于与我相似的情况。 我可能错了,但是从当前目录卸载cd path/to/site-packages && python3 -m pip uninstall spam似乎是一个边缘用例,如果有人知道这样做,那么为像我这样的口呼吸者调整的消息不会混淆他们。

似乎大多数用户只是假设 - 就像我一样;-) - uninstall会神奇地在系统库中找到包。

所有3条评论

也许将这种情况下的错误修改为Can't uninstall 'spam' (found in current directory). No files were found to uninstall.

@pfmoore我认为您编辑的消息绝对是一种改进(并且会节省我一些时间),但我会走得更远。 更有指导意义的东西怎么样,比如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. (如果有更精确的术语,请更改system library )。 是不是太啰嗦了?

似乎有人会遇到这条消息的唯一一次是他们是否处于与我相似的情况。 我可能错了,但是从当前目录卸载cd path/to/site-packages && python3 -m pip uninstall spam似乎是一个边缘用例,如果有人知道这样做,那么为像我这样的口呼吸者调整的消息不会混淆他们。

似乎大多数用户只是假设 - 就像我一样;-) - uninstall会神奇地在系统库中找到包。

也许“您的计算机”会比“系统库”更好?

迭代您的建议@reynoldsnlp

无法卸载“垃圾邮件”(在当前目录中)。 找不到要卸载的文件。\n要从您的计算机中卸载“垃圾邮件”,请从不包含“垃圾邮件”目录的目录中运行相同的命令。

是不是更清楚了?

此页面是否有帮助?
0 / 5 - 0 等级