我試圖在 VS 代碼中為 python 安裝格式化程式,當編輯器嘗試安裝格式化程式時,我收到以下錯誤:
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python310\\Scripts\\black.exe' -> 'C:\\Python310\\Scripts\\black.exe.deleteme
整個終端會話:
PS D:\playarea> & C:/Python310/python.exe -m pip install -U black
Collecting black
Downloading black-21.12b0-py3-none-any.whl (156 kB) |████████████████████████████████| 156 kB 469 kB/s---------------------------- Requirement already satisfied: platformdirs>=2 in c:\users\youse\appdata\roaming\python\python310\site-packages (from
black) (2.4.0)
Collecting tomli<2.0.0,>=0.2.6
Downloading tomli-1.2.2-py3-none-any.whl (12 kB)
Collecting pathspec<1,>=0.9.0
Downloading pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
Collecting typing-extensions>=3.10.0.0
Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Downloading click-8.0.3-py3-none-any.whl (97 kB)
gic
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python310\\Scripts\\black.exe' -> 'C:\\Python310\\Scripts\\black.exe.deleteme'
重要提示:我應該注意到那天早些時候我正在學習虛擬環境,并且我玩了很多關于應該使用哪個 python 解釋器 vs 代碼的問題,但是,我不明白哪里出了問題?
uj5u.com熱心網友回復:
添加--user引數,然后重試。
C:/Python310/python.exe -m pip install -U black --user
順便說一句,將 python 添加到 PATH對您來說很容易呼叫python.exe,您可以使用它python -m pip而不是使用完整路徑。
這是一個類似的問題:使用可執行檔案安裝包時出錯,這會驗證它是否與權限相關。在C:\Python310具有完全訪問權限的檔案夾安全面板中添加用戶解決了這個問題。
請試一試。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/378482.html
