anaconda / nb_conda

Conda environment and package access extension from within Jupyter
BSD 3-Clause "New" or "Revised" License
140 stars 32 forks source link

Run jupyter notebook in a conda env can't change kernel with correct $PATH #71

Open scku208 opened 6 years ago

scku208 commented 6 years ago

I install miniconda and create a env named "startup", then I install jupyter notebook and some extensions in it. I also create some other envs for different jobs, named like "sci", "gis",..., install required packages in it.

run terminal with:

source activate startup
jupyter-notebook

everything looks great, open an ipynb file and run cell:

import os
os.environ['PATH']

give the path like /Users/scku/miniconda3/envs/startup/bin:/Users/scku/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin"

run:

import sys
sys.path

give the path ['', '/Users/scku/miniconda3/envs/startup/lib/python36.zip', '/Users/scku/miniconda3/envs/startup/lib/python3.6', '/Users/scku/miniconda3/envs/startup/lib/python3.6/lib-dynload', '/Users/scku/miniconda3/envs/startup/lib/python3.6/site-packages', '/Users/scku/miniconda3/envs/startup/lib/python3.6/site-packages/IPython/extensions', '/Users/scku/.ipython']

but when I change kernel by "Kernel" -> "Change kernel" -> "conda env:sci" run

import os
os.environ['PATH']

get the confusion path (still "starup", no "sci") '/Users/scku/miniconda3/envs/startup/bin:/Users/scku/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin'

run

import sys
sys.path

get the path I expect ['', '/Users/scku/miniconda3/envs/sci/lib/python36.zip', '/Users/scku/miniconda3/envs/sci/lib/python3.6', '/Users/scku/miniconda3/envs/sci/lib/python3.6/lib-dynload', '/Users/scku/miniconda3/envs/sci/lib/python3.6/site-packages', '/Users/scku/miniconda3/envs/sci/lib/python3.6/site-packages/IPython/extensions', '/Users/scku/.ipython']

shouldn't the "changing kernel behavior" like (run with terminal):

#default path
KuShangChende-MacBook-Air:~ scku$ echo $PATH
/Users/scku/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
#startup path + default path
KuShangChende-MacBook-Air:~ scku$ source activate startup
(startup) KuShangChende-MacBook-Air:~ scku$ echo $PATH
/Users/scku/miniconda3/envs/startup/bin:/Users/scku/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
# sci path + startup path + default path
(startup) KuShangChende-MacBook-Air:~ scku$ source activate sci
(sci) KuShangChende-MacBook-Air:~ scku$ echo $PATH
/Users/scku/miniconda3/envs/sci/bin:/Users/scku/miniconda3/envs/startup/bin:/Users/scku/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin

Or I missed something? thanks for help.