簡體   English   中英

如何修復 pip 錯誤“查找 'pip' 的模塊規范時出錯(AttributeError:模塊 '__main__' 沒有屬性 '__file__')”?

[英]How to fix pip error "Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')"?

在虛擬環境中,我收到錯誤

path/to/python: Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')

當我運行命令時

python -m pip install --upgrade pip
python -m pip freeze

但是,當我使用pip運行相同的命令時,它可以工作,例如

pip install --upgrade pip
pip freeze

pythonpython3相同,版本為 3.8.12,我重新安裝了 pip 使用

pip install --force-reinstall pip

pip 版本為 21.3.1。

我還能做什么才能讓python -m pip命令再次起作用?

好吧,問題是正在使用一個版本 60.3.0,它有一個錯誤。 但是您不能安裝其他版本的setuptools ,因為您已經安裝了 60.3.0 版本。

解決方法:等待版本>60.3.0

暫無
暫無

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

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