简体   繁体   English

尝试在 Jupyter 笔记本中运行“black”时找不到模块

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

I've created a Jupyter notebook inside of a virtual environment.我在虚拟环境中创建了一个 Jupyter notebook。

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.在我的笔记本中,有一个带有小木槌的按钮可以运行black代码格式化。 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?关于让black正常运行的任何建议?

Run something like the answer here :这里运行类似答案的东西:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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