[英]Formatter black is not working on my VSCode...but why?
[英]Formatter Black not working for my VScode Jupyter Notebooks?
盡管 autopep8 正在工作,但我的黑色格式化程序從幾個月前開始在自動保存(延遲后)上格式化我的筆記本單元格時不再工作。 我使用虛擬環境來處理我的筆記本。 我也在那里安裝了黑色。 所以這是我的用戶設置:
"[python]": {
"editor.defaultFormatter": null,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.formatOnSave": true
},
"python.formatting.blackPath": "C:/Users/core i5/Documents/GitHub/DataScience/pyenv/Lib/site-packages/black",
當我嘗試格式化單元格時,output 如下所示:
> "~/Documents/GitHub/DataScience/pyenv/Lib/site-packages/black" --diff --quiet ".\CPE 312\KNN-SVM-NaiveBayes\Hands-on Activity 4.1 K Nearest Neighbors.ipynb.e65891a52a42197e13c75efc5b59ebe7.tmp"
cwd: .
> "~/Documents/GitHub/DataScience/pyenv/Lib/site-packages/black" --version
Formatting with black failed.
You could either install the 'black' formatter, turn it off or use another formatter.
Error: spawn C:/Users/core i5/Documents/GitHub/DataScience/pyenv/Lib/site-packages/black ENOENT
有誰知道該怎么做? 提前致謝!
如果 Black 已正確安裝到您的虛擬環境中,並且您的 VSCode 項目指向正確的環境,則您不必首先提供black.exe
的路徑。 package 提供了一個入口點,並且應該在激活虛擬環境的情況下“正常工作”。
我建議您完全刪除"python.formatting.blackPath"
設置。
如果出於某種原因您想提供一個顯式的 Black 路徑,您需要更改該設置。 不要指向Lib/site-packages/
中的目錄; 指向Scripts/
中的二進制文件,應該類似於
~/Documents/GitHub/DataScience/pyenv/Scripts/black.exe
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.