Black formatting in PyCharm
Hello future self and everone else wanting to use Black for formatting Python code using PyCharm. These are the steps that I took to make it work on my system, which runs Windows 10 Enterprise version 20H2. I have PyCharm Community Edition 2021.1.1 installed. My Python version is 3.7.8 and my Black version is 20.8b1. It is most likely that the following steps will work if you have a similar setup, but also probable it will work otherwise.
Steps to set Black up for use from within PyCharm:
- Open Terminal from PyCharm:
2. From the terminal in PyCharm, run the following commands:
pip install black
pip install aiohttp
pip install aiohttp_cors
3. To enable Black after having closed PyCharm or the first time after installing the above packages, run the following command from Terminal in PyCharm:
blackd
4. You can now call Black from the Tools menu for either a whole file or selection in file: