我正在为一个使用Python的客户开发一个DevOps项目。虽然我从来没有专业地使用过它,但我知道一些事情,比如使用virtualenv和pip -尽管不是很详细。
当我看着我试图为运行功能测试套件做准备的登台框时,我看到了混乱。大量安装在全球的软件包,以及那些安装在virtualenv中的软件包与项目的requirements.txt不匹配。好吧,我想,有很多清理工作要做。从全局包开始。
然而,我立刻遇到了一个问题:
➜ ~ pip uninstall PyYAML
Not uninstalling PyYAML at /usr/lib/python2.7/dist-packages, owned by OS好吧,一定是有人做了“sudo pip install PyYAML”。我想我知道如何修复它:
➜ ~ sudo pip uninstall PyYAML
Not uninstalling PyYAML at /usr/lib/python2.7/dist-packages, owned by OS嗯,显然我不知道。搜索发现一些类似的冲突是由用户绕过pip安装软件包引起的,但我不相信-如果是这样的话,pip为什么会知道它们呢?除非“另一种”方法是将它们放在pip会使用的相同位置-但如果是这样的话,为什么在sudo下卸载失败?
发布于 2018-06-07 07:44:35
Pip拒绝卸载这些软件包,因为Debian开发人员对其进行了修补,使其具有这样的行为。这允许您同时使用pip和apt。原始的pip程序没有这样的功能。
更新:我的答案只与旧版本的Pip相关。对于最新的版本,Pip被配置为只修改只存在于其“主目录”中的文件-即Debian的/usr/local/lib/python3.*。对于最新的工具,当您尝试删除由apt安装的软件包时,会收到以下错误
对于pip 9.0.1-2.3~ubuntu1 (从Ubuntu存储库安装):
Not uninstalling pyyaml at /usr/lib/python3/dist-packages, outside environment /usr对于pip 10.0.1 (原始版本,从pypi.org安装):
Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.https://stackoverflow.com/questions/50730946
复制相似问题