无法卸载没有包的项目

2024-04-26 03:14:10 发布

您现在位置:Python中文网/ 问答频道 /正文

在为另一个问题构建MCVE时,我创建了一个example目录,其中包含一个文件setup.py,内容如下:

from setuptools import setup

setup(
    name='example',
)

并安装了

python3.6 setup.py sdist
python3.6 -m pip install --user dist/example-0.0.0.tar.gz

没有实际的软件包或模块,但是安装了一些东西:

redacted:~/example> python3.6 -m pip list | grep example
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
example (0.0.0)

现在我无法卸载它:

redacted:~/example> python3.6 -m pip uninstall example
Can't uninstall 'example'. No files were found to uninstall.

Other posts建议可能有一个.pth文件我必须从site-packages目录中删除,但我没有看到任何文件:

redacted:~/example> find ~/.local/lib/python3.6/site-packages/ -name '*.pth'
redacted:~/example> 

我刚才对我的系统做了什么,我怎样才能撤消它?你知道吗


Tags: pipcolumns文件thetonameinpy
2条回答

因为您没有指定任何文件,所以没有要安装的文件。所以你也不能卸载任何东西。你知道吗

看起来这个可能没有安装任何东西。甚至元数据都没有,尽管一开始看起来是这样。你知道吗

将pip作为python3.6 -m pip而不是pip3.6运行会将当前目录放在导入路径上—在我的示例中,当前目录是具有setup.py和由python3.6 setup.py sdist构建的目录的目录。pip搜索导入路径以查找已安装的包,当它运行到空项目的元数据中时,它会感到困惑。似乎发现此处列出的所有0个文件都已安装,因此必须安装该项目。你知道吗

在同一目录中运行python2.7 -m pip list也会为example (0.0.0)生成一个条目,尽管我肯定没有在2.7上安装它。运行pip2.7 listpip3.6 list不会显示条目。从其他目录运行python2.7 -m pip listpython3.6 -m pip list也不会显示条目:

redacted:~/example> python2.7 -m pip list 2>&1 | grep example
example (0.0.0)
redacted:~/example> python3.6 -m pip list 2>&1 | grep example
example (0.0.0)
redacted:~/example> pip2.7 list 2>&1 | grep example
redacted:~/example> pip3.6 list 2>&1 | grep example
redacted:~/example> cd
redacted:~> python2.7 -m pip list 2>&1 | grep example
redacted:~> python3.6 -m pip list 2>&1 | grep example
redacted:~> 

考虑到这个输出,我不认为我需要做任何事情来卸载这个包。你知道吗

相关问题 更多 >