Running Jupyter notebook --- Existing python 3.5 interferes

Hi there,

I’m trying to run a MAF tutorial in a jupyter notebook and I am getting this error when I try to start jupyter:

*******@sc:~/lsst_stack$ jupyter notebook
Traceback (most recent call last):
File "/home/nicholas/anaconda3/lib/python3.6/site-packages/notebook/nbextensions.py", line 18, in <module>
from urllib.request import urlretrieve
File "/home/nicholas/anaconda3/lib/python3.6/urllib/request.py", line 88, in <module>
import http.client
File "/home/nicholas/lsst_stack/Linux64/python_future/0.16.0/lib/python/future-0.16.0-py2.7.egg/http/__init__.py", line 
7, in <module>
 raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future 
src folder or your installation of python-future is corrupted.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/nicholas/anaconda3/bin/jupyter-notebook", line 4, in <module>
 import notebook.notebookapp
File "/home/nicholas/anaconda3/lib/python3.6/site-packages/notebook/__init__.py", line 25, in <module>
 from .nbextensions import install_nbextension
File "/home/nicholas/anaconda3/lib/python3.6/site-packages/notebook/nbextensions.py", line 20, in <module>
 from urlparse import urlparse
ModuleNotFoundError: No module named 'urlparse'

Here are the steps I took to install the LSST stack and MAF:

mkdir -p $HOME/lsst_stack
cd $HOME/lsst_stack

unset LSST_HOME EUPS_PATH LSST_DEVEL EUPS_PKGROOT REPOSITORY_PATH

curl -OL https://raw.githubusercontent.com/lsst/lsst/13.0/scripts/newinstall.sh
bash newinstall.sh
    [yes to miniconda installation]

source loadLSST.bash
eups distrib install lsst_sims -t sims


setup sims_maf -t sims


eups list -v sims_maf

Where the output from that last command is:

2.3.6.sims /home/nicholas/lsst_stack /home/nicholas/lsst_stack/Linux64/sims_maf/2.3.6.sims  	sims current sims_2_3_6 setup

So I feel that I have installed the LSST stack properly, but I don’t know how to get jupyter notebook running without the above error.

I can run jupyter notebook fine from a new terminal ,i.e. before I run

source loadLSST.bash
setup sims_maf -t sims

But if I try to run the python notebook tutorial, it breaks here:

# Import required dependencies from LSST stack
import lsst.sims.maf.db as db

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5804c9d8b44d> in <module>()
  5 
  6 # Import required dependencies from LSST stack
----> 7 import lsst.sims.maf.db as db
  8 import lsst.sims.maf.metrics as metrics
  9 import lsst.sims.maf.slicers as slicers

ModuleNotFoundError: No module named 'lsst'

I think there is some conflict arising from the installation of python3 which was on the system before I started the installation of the LSST stack. Is there a solution?

This is your python 3 installation.

This is your python 2.7 stack.

I assume the anaconda3 is the python running inside your notebook.
When you ran source loadLSST.bash from the shell that should have put your python2 into the front of $PATH and let you built your own stack. That all seems fine. The next question is what python your Jupyter notebook is using. If that is a python3 then there is no way it can load a stack you built for python2. If you are building your own code inside a notebook environment you have to ensure that you are using the same python that is running your notebook.

As an aside, is there a reason you are using a python2 stack build and not python3?

Thanks @timj, much appreciated. Your comments all make sense. I suspect that I built Jupyter using Python3 on the machine showing the problem.

I installed and built Jupyter using Python2 on my laptop following the same install sequence I gave in my question and all appears to be working fine (so far).

The machine I want to us is the one on which I’ve installed Jupyter using python3, rather than my laptop.

From your aside, it appears that there is a python3 stack available. How do I amend my LSST stack install commands (“Here are the steps I took to install the LSST stack and MAF:”) above, to pull down and install a python3 LSST stack?

Add -3 option to newinstall.sh (bash newinstall.sh -3)