Jupyter lab installing/importing packages

后端 未结 1 729
Happy的楠姐
Happy的楠姐 2021-01-24 10:12

I am trying to install plotnine for a notebook I am using. I have done the following:

  1. Created a conda environment using python 3.6, an

相关标签:
1条回答
  • 2021-01-24 10:42

    I had the same problem. It looks like for me, my notebook in Jupyter Lab was running the base kernel and not the kernel of the virtual environment. Type

    import sys
    sys.executable
    

    into your notebook. For me, I got the result

    '/anaconda3/bin/python'
    

    instead of the desired

    '/anaconda3/envs/myenv/bin/python'
    

    I solved it by following the instructions in the iPython documentation. In summary, you need to install a new iPython kernel for your new environment. Run:

    conda install -n myenv ipython
    conda activate myenv
    python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
    

    Then, to run Jupyter Lab in the new environment:

    conda activate myenv
    jupyter lab
    

    And you should be able to select the kernel "Python (myenv)" when you open a new notebook (also in the top right of an existing notebook).

    0 讨论(0)
提交回复
热议问题