pythonipythonjupyter-notebookjupyter-console

check which conda env jupyter console is using


I have a conda environment and I would like to run a jupyter console within that environment. I do the usual source activate myenv and then jupyter console. The source activate myenv works since which python points to the right path. However, it doesn't seem like the jupyter console is picking up the right env. I have done this:

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

I have nb_conda and nb_conda_kernels installed. What's going on with my setup? I have Ipython 6.4.0, Python 3.6.5. Also, coming from an R background, I find it weird that I'm spending so much time on the basic setup where in R things just work. Is there something I'm missing or doing wrong? How can i check which env Ipython is running in?


Solution

  • sys.executable does indeed give you that info. This is how one should actually start the correct kernel (provided by How to start an ipython shell(not notebook) within a conda or virtualenv):

    source activate myenv
    python -m ipykernel install --user --name myenv --display-name "myenv"
    jupyter console --kernel myenv
    

    To get a list of the kernels that can be used:

    jupyter kernelspec list