I'm using Anaconda to manage both Python and Jupyter. That is:
>> which python
>> /home/.../software/anaconda3/bin/python
and
>> which jupyter
>> /home/.../software/anaconda3/bin/jupyter
But Jupyter's python kernel seems to be pointing to a system version of Python rather than my local version through Anaconda, since the sys.path is different in a Jupyter Python 3 notebook. Also, jupyter kernelspec list gives the following:
Available kernels:
ir /usr/local/share/jupyter/kernels/ir
matlab /usr/local/share/jupyter/kernels/matlab
python3 /usr/local/share/jupyter/kernels/python3
This doesn't seem altogether surprising since the docs say in section 1.5.5:
By default, kernel specs will go in a system-wide location (e.g. /usr/local/share/jupyter/kernels). If doing a --user install, the kernel specs will go in the JUPYTER_DATA_DIR location.
For personal sanity and organization, I want the version of Python that I use in the command line to be the same that is accessed in Jupyter. As a result, I think that what I should do is change my jupyter kernelspec list for python3 so that it points to my desired Anaconda python version, i.e. /home/.../software/anaconda3/bin/python. My questions are: 1) is that indeed the best solution for my stated preferences, and 2) how do I actually change my jupyter kernelspec entry for python3? Not sure if this will come up, but I don't want to be using virtual environments--I want the default to be same version of Python across both the command line and Jupyter.
解决方案
I ended up reposting this to the Jupyter Github issues page, and was recommended to delete /usr/local/share/jupyter/kernels/python3. This allows Jupyter to find a default Python kernel using the same Python running Jupyter itself (i.e. Anaconda), and this worked for me.
You can find my post on Jupyter's Github page as well as an explanation for why the above solution works here.