环境
描述
我使用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.
以更有助于指示失败可能是因为存在具有目标包名称的本地文件夹。
也许将这种情况下的错误修改为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要从您的计算机中卸载“垃圾邮件”,请从不包含“垃圾邮件”目录的目录中运行相同的命令。
是不是更清楚了?
最有用的评论
@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
会神奇地在系统库中找到包。