簡體   English   中英

無法卸載沒有包的項目

[英]Can't uninstall project with no packages

在嘗試為另一個問題構建 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.

其他帖子表明可能有一個.pth文件我必須從我的site-packages目錄中刪除,但我沒有看到任何:

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

我剛剛對我的系統做了什么,我該如何撤消它?

由於您沒有指定任何文件,因此無需安裝任何文件。 所以你也不能卸載任何東西。

看起來這可能沒有安裝任何東西。 甚至元數據都沒有,盡管一開始似乎是這樣。

運行 pip as python3.6 -m pip而不是pip3.6將當前目錄放在導入路徑上——在我的例子中,當前目錄是帶有setup.py和由python3.6 setup.py sdist構建的目錄的目錄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:~> 

鑒於這個輸出,我認為我不需要做任何事情來卸載這個包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM