Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'notebook.services' #4436

Open
naifrec opened this issue Mar 1, 2019 · 5 comments
Open

ModuleNotFoundError: No module named 'notebook.services' #4436

naifrec opened this issue Mar 1, 2019 · 5 comments

Comments

@naifrec
Copy link

naifrec commented Mar 1, 2019

Hello,

I am encountering the following issue:

$ jupyter notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 6, in <module>
    from notebook.notebookapp import main
  File "/usr3/ams/radio/gsautie/.local/lib/python3.6/site-packages/notebook/notebookapp.py", line 79, in <module>
    from .base.handlers import Template404, RedirectWithParams
  File "/usr3/ams/radio/gsautie/.local/lib/python3.6/site-packages/notebook/base/handlers.py", line 44, in <module>
    from notebook.services.security import csp_report_uri
ModuleNotFoundError: No module named 'notebook.services'

I know there is a related to the following stack overflow thread. However the provided answer (pip install jupyter) is not solving the problem as jupyter is properly installed, since I am running it from a docker container where jupyter is installed, see Dockerfile below.

I am not exactly sure how to proceed. Here are some useful output:

$ which python
/usr/bin/python
$  python
Python 3.6.7 (default, Oct 25 2018, 09:16:13) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
$ which jupyter
/usr/local/bin/jupyter
$ cat /usr/local/bin/jupyter
$ cat /usr/local/bin/jupyter
#!/usr/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys

from jupyter_core.command import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
$ pip list
Package             Version               
------------------- ----------------------
attrs               18.2.0                
backcall            0.1.0                 
backports.weakref   1.0rc1                
bleach              1.5.0                 
cycler              0.10.0                
decorator           4.3.2                 
defusedxml          0.5.0                 
entrypoints         0.3                   
fire                0.1.3                 
h5py                2.9.0                 
html5lib            0.9999999             
ipykernel           5.1.0                 
ipython             7.3.0                 
ipython-genutils    0.2.0                 
ipywidgets          7.4.2                 
jedi                0.13.3                
Jinja2              2.10                  
jsonschema          3.0.0                 
jupyter             1.0.0                 
jupyter-client      5.2.4                 
jupyter-console     6.0.0                 
jupyter-core        4.4.0                 
Keras               2.2.4                 
Keras-Applications  1.0.7                 
Keras-Preprocessing 1.0.9                 
kiwisolver          1.0.1                 
Markdown            2.2.0                 
MarkupSafe          1.1.1                 
matplotlib          3.0.3                 
mistune             0.8.4                 
nbconvert           5.4.1                 
nbformat            4.4.0                 
notebook            5.7.4                 
numpy               1.16.0                
pandocfilters       1.4.2                 
parso               0.3.4                 
pexpect             4.6.0                 
pickleshare         0.7.5                 
pip                 19.0.3                
prometheus-client   0.6.0                 
prompt-toolkit      2.0.9                 
protobuf            3.7.0                 
ptyprocess          0.6.0                 
pycurl              7.43.0                
Pygments            2.3.1                 
pygobject           3.20.0                
pyparsing           2.3.1                 
pyrsistent          0.14.11               
python-apt          1.1.0b1+ubuntu0.16.4.2
python-dateutil     2.8.0                 
PyYAML              3.13                  
pyzmq               18.0.0                
qtconsole           4.4.3                 
scipy               1.2.1                 
Send2Trash          1.5.0                 
setuptools          40.8.0                
six                 1.12.0                
tensorflow-gpu      1.2.0                 
terminado           0.8.1                 
testpath            0.4.2                 
torch               0.4.1                 
tornado             5.1.1                 
tqdm                4.31.1                
traitlets           4.3.2                 
unattended-upgrades 0.1                   
wavenet             0.0.8                 
wcwidth             0.1.7                 
Werkzeug            0.14.1                
wheel               0.33.1                
widgetsnbextension  3.4.2
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04

# Without this I get unicode errors when printing large torch	tensors
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

# solve bug with some docker installs
RUN apt-get update -y
RUN apt-get install -y python2.7
RUN ln -s /usr/bin/python2.7 /usr/bin/python2

# install python3.6
RUN apt-get update -y
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:jonathonf/python-3.6
RUN apt-get update -y
RUN apt-get install -y python3.6
# install dev headers
RUN apt-get update -y
RUN apt-get install -y python3.6-dev
RUN ln -s /usr/bin/python3.6 /usr/bin/python

# install pip
RUN apt-get update -y
RUN apt-get install -y wget
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.6 get-pip.py

RUN pip3.6 install keras==2.2.4
RUN pip3.6 install numpy==1.16.0
RUN pip3.6 install tensorflow-gpu==1.2.0
RUN pip3.6 install torch==0.4.1
RUN pip3.6 install fire
RUN pip3.6 install h5py==2.9.0
RUN pip3.6 install jupyter
RUN pip3.6 install matplotlib
RUN pip3.6 install tqdm

# setup CUDA for tensorflow: https://github.com/tensorflow/tensorflow/issues/8898#issuecomment-311608341
RUN sh -c "echo '/usr/local/cuda/lib64\n/usr/local/cuda/lib' >> /etc/ld.so.conf.d/nvidia.conf"
RUN ldconfig
@paulrigor
Copy link

Any updates or work-around for this? @naifrec Thanks!

@Zsailer
Copy link
Member

Zsailer commented Mar 10, 2021

@paulrigor, are you seeing the same issues with the notebook version mentioned above, i.e. notebook==5.7.4, and Ubuntu 16.04?

There might be something wrong with that specific version of notebook on Ubuntu.

@sam-s
Copy link

sam-s commented Jan 6, 2025

I see this with notebook 7.3.1 and jupyter 1.1.1

@PaleNeutron
Copy link

PaleNeutron commented Jan 15, 2025

For anyone face the problem with errors and env below, just use pip install "notebook<7" will fix it.

$ jupyter nbconvert dev/idx_test.ipynb --to html --output idx_test.html 
Traceback (most recent call last):
  File "/home/john/projects/cell-strategy-backend/.venv/bin/jupyter-nbconvert", line 5, in <module>
    from nbconvert.nbconvertapp import main
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 193, in <module>
    class NbConvertApp(JupyterApp):
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 252, in NbConvertApp
    Options include {get_export_names()}.
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/nbconvert/exporters/base.py", line 145, in get_export_names
    e = get_exporter(exporter_name)(config=config)
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/nbconvert/exporters/base.py", line 106, in get_exporter
    exporter = items[0].load()
  File "/home/john/.pyenv/versions/3.10.14/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/home/john/.pyenv/versions/3.10.14/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/jupyter_contrib_nbextensions/nbconvert_support/__init__.py", line 5, in <module>
    from .collapsible_headings import ExporterCollapsibleHeadings
  File "/home/john/projects/cell-strategy-backend/.venv/lib/python3.10/site-packages/jupyter_contrib_nbextensions/nbconvert_support/collapsible_headings.py", line 6, in <module>
    from notebook.services.config import ConfigManager
ModuleNotFoundError: No module named 'notebook.services'
jupyter --version                                                    
Selected Jupyter core packages...
IPython          : 8.26.0
ipykernel        : 6.29.4
ipywidgets       : 8.1.5
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.15.0
jupyterlab       : 4.3.4
nbclient         : 0.10.2
nbconvert        : 7.16.5
nbformat         : 5.10.4
notebook         : 7.3.2
qtconsole        : not installed
traitlets        : 5.14.3

@Liouchengkai
Copy link

@PaleNeutron thanks. It works for me to use nbconvert, but I cannot open jupyter notebook anymore with downgrade version. Can somebody help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants