Open ssamdani-1729 opened 5 years ago
As the tool needs to be installed in /usr/local/bin/black
I guess there is no way for windows. You might try the ubuntu-shell for windows?
You can configure the pycharm plugin from pycharm's file -> settings -> tools menu. There you can set the path to the black executable.
You can also setup an external tool hook in pycharm, also in settings > tools. However this won't use the plugin but will run the tool directly.
I would love to see either of the following two things in order to make the plugin work on windows:
C:\Program Files\Python36\Scripts\black.exe
as the default path(obviously the 1st being the easier option).
As per Black's documentation section on integrations, no plugin is required to use Black in PyCharm.
Here's a working procedure for v19.10b1.dev49 which is the current latest at the date of this post:
$ pip install black
$ which black
/usr/local/bin/black
^-possible location-^
$ where black
%LocalAppData%\Programs\Python\Python36-32\Scripts\black.exe
^-possible location-^
PyCharm -> Preferences -> Tools -> External Tools
File -> Settings -> Tools -> External Tools
Click the +
icon to add a new external tool with the following values:
Black
Black is the uncompromising Python code formatter.
<path to your local installation>
"$FilePath$"
Format the currently opened file by selecting Tools -> External Tools -> black.
Alternatively, you can set a keyboard shortcut by navigating to Preferences
or Settings
-> Keymap -> External Tools -> External Tools - Black
⚠ Make sure you have the File Watcher plugin installed.
Go to Preferences or Settings -> Tools -> File Watchers and click + to add a new watcher:
Black
Python
<path to your local installation>
$FilePath$
$FilePath$
$ProjectFileDir$
Auto-save edited files to trigger the watcher
I'm wondering how I can make this work on a windows version of Pycharm. I have installed the black tool in a conda virtual environment and this same virtual environment is being used by PyCharm.