pythonpycharmcondapython-black

Install black[d] from conda


I want to run black as a code formatter in PyCharm. The black website gives specific instructions on how to do so, which is very helpful: https://black.readthedocs.io/en/stable/integrations/editors.html . However, it uses pip to install black[d] while I would like to use conda instead to take advantage of the dependency solver and to have a leaner process.

If I try to simply add black, black[d], or "black[d]" to the env.yaml file for conda, it installs the simple black package without the additional dependencies added by the optional [d]. Why is this happening? Is this syntax not accepted by conda or is something missing from the conda-forge repos?


Solution

  • That syntax is not supported. There are no formal rules for how PyPI packages translate to Conda packages - just have to search and find. For Conda Forge, the black-feedstock builds both black and blackd, which is what you want.

    mamba install -c conda-forge blackd