Running Jupyter notebook in a virtualenv: installed sklearn module not available

前端 未结 7 2186
小蘑菇
小蘑菇 2020-12-13 09:33

I have installed a created a virtualenv machinelearn and installed a few python modules (pandas, scipy and sklearn) in that environment.

When I run

7条回答
  •  春和景丽
    2020-12-13 10:24

    Another approach to take is to have one global jupyter installation, but to point to different kernels to run as the backend.

    That approach is outlined here in their docs: http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs

    Copying below in case the link breaks: You can use a virtualenv for your IPython notebook. Follow the following steps:

    Install the ipython kernel module into your virtualenv

    workon my-virtualenv-name  # activate your virtualenv, if you haven't already
    pip install ipykernel
    

    Now run the kernel "self-install" script:

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

    Replacing the --name parameter as appropriate.

    You should now be able to see your kernel in the IPython notebook menu: Kernel -> Change kernel and be able so switch to it (you may need to refresh the page before it appears in the list). IPython will remember which kernel to use for that notebook from then on.

提交回复
热议问题