Module not found when trying to run `black` in a Jupyter notebook

1.2k views Asked by At

I've created a Jupyter notebook inside of a virtual environment.

These packages are installed:

black==22.12.0
jupyter~= 1.0.0
jupyter-black==0.3.3
jupyter-contrib-nbextensions~=0.5.1

In my notebook, there's a button with a little gavel to run black code formatting. However, when I click this, I get the error message:

localhost:8888 says 

[jupyter-black]
 Error:ModuleNotFoundError
No module named 'black'

I've made sure I'm using the kernel created inside this virtual environment.

Reading through the docs has not pointed out any obvious errors I'm making here. Any suggestions on getting black to run appropriately?

1

There are 1 answers

0
canary_in_the_data_mine On

Run something like the answer here:

python -m ipykernel install --name=my-virtualenv-name