简体   繁体   中英

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

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?

Run something like the answer here :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM