EDIT: I have now fixed this problem by following this solution
I am trying to use Jupyter Notebook with anaconda. I have installed anaconda and when I run python in the shell it has the correct anadonda sys.path:
python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print('\n'.join(sys.path))
/home/morgan/anaconda3/lib/python37.zip
/home/morgan/anaconda3/lib/python3.7
/home/morgan/anaconda3/lib/python3.7/lib-dynload
/home/morgan/anaconda3/lib/python3.7/site-packages
However, when I do the same within Jupyter notebook, the sys.path
has not been updated from when I installed anaconda:
import sys
print ('\n'.join(sys.path))
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/home/morgan/.local/lib/python3.6/site-packages
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
/home/morgan/.local/lib/python3.6/site-packages/IPython/extensions
/home/morgan/.ipython
This has been a problem as I could not load packages installed using conda into Jupyter Notebook. I tried using this solution, in which the ipython_config
file is edited to add additional entries to the sys.path
, so now when I print sys.path
in Jupyter Notebook it gives me this:
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/home/morgan/.local/lib/python3.6/site-packages
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
/home/morgan/.local/lib/python3.6/site-packages/IPython/extensions
/home/morgan/.ipython
/home/morgan/anaconda3/lib/python3.7/site-packages /home/morgan/anaconda3/lib/python3.7
/home/morgan/anaconda3/lib/python3.7/lib-dynload
I have found including only /home/morgan/anaconda3/lib/python3.7/site-packages
allows jupyter notebook to find packages installed using conda, but it causes matplotlib to break. Including all three additional addresses causes it to not be able to find the packages at all.
I would like to be able to edit the sys.path
for Jupyter Notebook directly as using this solution I can only add lines, not delete the lines that are already there.
I have tried uninstalling and reinstalling Jupyter Notebook.
I am running the Ubuntu 18.04.2 LTS
as a Linux subsystem within Windows 10 (I am running everything including Jupyter notebook through this). As you can see I have python 3.7
installed from anaconda
and python 3.6
in .local/lib
.