Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't launch Jupyter Notebook ModuleNotFoundError: No module named 'resource'

I've been using Jupyter Notebook from the command line for a month now, today I didn't shut the running notebook and put my laptop to sleep for 4 hours. After turning my laptop back on I tried to run the notebook again and I'm getting the same error ever since. Please help me out.

Traceback (most recent call last):
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 27, in <module>
    import resource
ModuleNotFoundError: No module named 'resource'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Chinmay\AppData\Local\Programs\Python\Python38-32\Scripts\jupyter-notebook.EXE\__main__.py", line 9, in <module>
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1769, in initialize
    self.init_webapp()
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1451, in init_webapp
    self.web_app = NotebookWebApplication(
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 153, in __init__
    settings = self.init_settings(
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 269, in init_settings
    nbextensions_path=jupyter_app.nbextensions_path,
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1120, in nbextensions_path
    from IPython.paths import get_ipython_dir
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\__init__.py", line 49, in <module>
    from .terminal.embed import embed
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
    from IPython.terminal.ipapp import load_default_config
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\ipapp.py", line 30, in <module>
    from IPython.core.magics import ScriptMagics
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\__init__.py", line 21, in <module>
    from .execution import ExecutionMagics
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\execution.py", line 46, in <module>
    from IPython.utils.timing import clock, clock2
  File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 64, in <module>
    clocku = clocks = clock = time.clock
AttributeError: module 'time' has no attribute 'clock'```
like image 633
Chinmay Parab Avatar asked Apr 01 '20 08:04

Chinmay Parab


3 Answers

Open this file: c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py

  1. change import time to import timeit
  2. change time.clock to timeit.default_timer

This worked for me, should work for you.

like image 95
Omkar Avatar answered Nov 20 '22 01:11

Omkar


conda update --all

this working

like image 3
horizon Avatar answered Nov 20 '22 01:11

horizon


For me this happened while trying to install some other pip libraries. Looks like one of my pip libraries got downgraded and that caused this error. So upgrading it back resolved the issue.

pip3 install --upgrade jupyter-console
pip3 install --upgrade jupyter
like image 3
kmchmk Avatar answered Nov 20 '22 03:11

kmchmk