python-3.x pip卸载:“找不到要解除安装的档案,”

jk9hmnmh  于 2022-12-05  发布在  Python
关注(0)|答案(5)|浏览(313)

我已经创建了一个python模块,叫它'foo_bar'。
我可以安装它,也可以升级它,但我无法卸载它。
我使用bdist_wheel构建我的模块:

$ python3 setup.py bdist_wheel

我安装和升级它如下:

$ python3 -m pip --timeout 60 install --upgrade dist/foo_bar-1.4.3-py3-none-any.whl

它在Python 3.4框架目录中列出:

ls -al /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/
drwxr-xr-x   12 samwise  admin     408 Jun 21 02:50 foo_bar
drwxr-xr-x    9 samwise  admin     306 Jun 21 02:50 foo_bar-1.4.3.dist-info

并且它在pip freeze内列出:

$ python3 -m pip freeze
foo-bar==1.4.3

但是,如果我尝试执行pip卸载,它找不到它的文件

$ python3 -m pip uninstall foo-bar
Can't uninstall 'foo-bar'. No files were found to uninstall.

我在www.example.com中做错了什么吗setup.py?在卸载过程中,它无法找到我的模块文件?
版本信息如下:

$ python3 --version
Python 3.4.4
$ python3 -m pip --version
pip 8.1.2 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)
dgenwo3n

dgenwo3n1#

我也遇到了同样的问题。使用verbose帮助我找出了更多的原因:

$ pip3 uninstall --verbose my-homemade-package
Not sure how to uninstall: my-homemade-package e48e635 - Check: /home/olivier/my-homemade-package
Can't uninstall 'my-homemade-package'. No files were found to uninstall.

删除/usr/local/python2.x/usr/local/python3.x中所有与“my-homestine-package”相关的内容并没有帮助。
我执行了一个pip3 show my-homemade-package,并获得了安装包在我计算机上的位置:

$ pip3 show my-homemade-package
Name: my-homemade-package
Version: e48e635
Summary: My Home Made package
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: Proprietary
Location: /home/olivier/my-homemade-package
Requires: pyOpenSSL, pyasn1, protobuf

删除/home/olivier/my-homemade-package解决了问题(即:未列出软件包)。

efzxgjgh

efzxgjgh2#

这是一个旧的帖子,但它是谷歌的顶级结果。上面的答案是正确的,但在我的情况下,仍然有行/usr/local/lib/python3.6/site-packages/easy-install.pth,我不得不删除后,也删除了鸡蛋文件。

7gcisfzg

7gcisfzg3#

所以我遇到了一个类似于OP的问题。我可以用pip install dist/mypackage.tar.gz安装我的包。安装会很好地工作,但在最后它会显示Can't uninstall 'mypackage'. No files were found to uninstall.,实际上pip uninstall mypackage以后就不能工作了。
这听起来很傻,但对我来说,有效的方法是 * 更改工作目录 *:一旦我离开mypackage/目录,pip uninstall mypackage就可以工作了。

oaxa6hgo

oaxa6hgo4#

当我在setup.py中重命名我的模块时遇到了这样的问题。
旧的old_name.egg-info目录仍然存在于my_module目录中。所以,当我用pip install -e . pip安装模块时,在python3.8/site-packages/easy-install.pth中创建了一行指向模块目录。之后,模块被pip list列出,两个名称都是:new-nameold-name。当我试图删除旧模块与pip remove old-name pip显示错误:

Found existing installation: old-name 0.3.0
Can't uninstall 'old-name'. No files were found to uninstall.

解决方案是从模块目录中删除目录old_name.egg-info。之后pip list只显示new-name
也许这不是对原帖的直接回答,而是解决主题名称问题的方法之一。

lmyy7pcs

lmyy7pcs5#

Issue: User cannot uninstall a python package installed via pip:

pip uninstall youtube-dl
Found existing installation: youtube-dl 2021.12.17
Not uninstalling youtube-dl at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'youtube-dl'. No files were found to uninstall.

Reason: PEBKAC.
Well, a simple

apt purge youtube-dl

did the trick. There had been a system package "youtube-dl" installed, with said version:

dpkg -l youtube-dl
ii  youtube-dl     2021.12.17-1~nd110+1

At the same time users used to install packages locally using pip. Both packages of the same version (2021.12.17). And both ways (apt and pip) referred to the packages by the same name. Turned out, this tends to confuse users..
Next level: Have a package installed three ways: apt, pip --system and plain pip as user. Maybe pip as root (locally) FWIW, too.

相关问题