[Python] Confusion about virtual environment and kernels in jupyter notebook

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I created a virtual environment called "fastai" by conda. I tried to install ipywidgets in it by

    mamba install ipywidgets


    Then I checked it and it did exist. But when I used

    jupyter --version


    I found the status of ipywidgets was "Not installed". I guessed it might be the problem of jupyter kernel, and I registered a kernel for my virtual environment fastai:

    python -m ipykernel install --user --name fastai --display-name "Python (fastai)"


    I checked the new kernel by

    jupyter kernelspec list


    and it did succeed. Then I opened a notebook by

    jupyter notebook


    and shifted the kernel to the one I created with my virtual env fastai. But I stilled failed to import ipywidgets in the notebook. What's more,

    jupyter --version


    also kept that ipywidgets could not be found. I checked my widgetsnbextension, but found both the base env and the virtual env had already had it. That's what I got in my Powershell. I wonder what's going on, and how I can use ipywidgets in my virtual env successfully.

    Continue reading...

Compartilhe esta Página