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

前端 未结 7 2218
小蘑菇
小蘑菇 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:33

    To use Jupyter notebook with virtual environment (using virtualenvwrapper) plus packages installed in that environment, follow steps below:

    1. create a virtual environment

      mkvirtualenv --no-site-packages --python=/your/python/path your_env_name
      
    2. Activate the virtual environment

      workon your_env_name
      
    3. Install Jupyter and other packages

      pip install jupyter, numpy
      
    4. Add a new kernel to your Jupyter config

      ipython kernel install --user --name=your_env_name
      
    5. Done. You may now use Jupyter notebook under the virtual environment.

      jupyter-notebook
      

    Disclaimer: the question has been answered but is hidden in one of the replies. I googled and took sometime to find the right answer. So I just summarize it so someone having the same issue can easily follow.

提交回复
热议问题