kirbs- / hide_code

Code, prompt and output hiding for Jupyter/IPython notebooks.
MIT License
371 stars 44 forks source link

Installation problem - No module named hide_code_html_exporter #89

Closed kjkeefe closed 4 years ago

kjkeefe commented 4 years ago

I am trying to install hide_code. It is exactly what I've been looking for for my jupyter notebooks. Please let me know what I can do to fix this error!

$ jupyter nbextension install --py hide_code
Traceback (most recent call last):
  File "/Users/kjkeefe/anaconda2/bin/jupyter-nbextension", line 8, in 
    sys.exit(main())
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 257, in start
    self.subapp.start()
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 716, in start
    self.install_extensions()
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 695, in install_extensions
    **kwargs
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 211, in install_nbextension_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 1122, in _get_nbextension_metadata
    m = import_item(module)
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/traitlets/utils/importstring.py", line 42, in import_item
    return __import__(parts[0])
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/hide_code/__init__.py", line 1, in 
    from hide_code.hide_code_html_exporter import HideCodeHTMLExporter
  File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/hide_code/hide_code.py", line 9, in 
    from hide_code.hide_code_html_exporter import HideCodeHTMLExporter
ImportError: No module named hide_code_html_exporter
kirbs- commented 4 years ago

Looks like hide_code isn't installed. What does pip list show?

kjkeefe commented 4 years ago

I think it is installed. When I do

pip list
, I get the following entry:

hide-code                0.5.5

I am using a Macbook running Mojave. It is running Python 2.7.16 Anaconda.

javierrodenas commented 4 years ago

Hi,

same is happening to me. I can't see the extension because of this error. Any solution?

Thanks!!

javierrodenas commented 4 years ago

Hi,

I have found the solution. With version 0.5.0 it works

pip install hide_code==0.5.0 jupyter nbextension enable hide_code --py jupyter nbextension enable hide_code --py

kirbs- commented 4 years ago

I'll check it out

kjkeefe commented 4 years ago

I tried @javierrodenas 's solution. Although, I changed his second line to:

jupyter nbextension install hide_code --py

This all appeared to work and I was able to launch jupyter-notebook. However, when I opened a notebook or created a brand new one, I got this exception on the console:

[E 14:04:59.419 NotebookApp] Uncaught exception GET /notebooks/Untitled2.ipynb?kernel_name=python2 (::1)
    HTTPServerRequest(protocol='http', host='localhost:8889', method='GET', uri='/notebooks/Untitled2.ipynb?kernel_name=python2', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/tornado/web.py", line 1590, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/tornado/web.py", line 3006, in wrapper
        return method(self, *args, **kwargs)
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/notebook/handlers.py", line 59, in get
        get_custom_frontend_exporters=get_custom_frontend_exporters
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/base/handlers.py", line 519, in render_template
        return template.render(**ns)
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 1090, in render
        self.environment.handle_exception()
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/templates/page.html", line 153, in top-level template code

      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/templates/notebook.html", line 120, in block "header"
        {% for exporter in get_custom_frontend_exporters() %}
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/notebook/notebook/handlers.py", line 24, in get_custom_frontend_exporters
        exporter = get_exporter(name)()
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/base.py", line 98, in get_exporter
        return entrypoints.get_single('nbconvert.exporters', name).load()
      File "/Users/kjkeefe/anaconda2/lib/python2.7/site-packages/entrypoints.py", line 82, in load
        mod = import_module(self.module_name)
      File "/Users/kjkeefe/anaconda2/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: No module named HideCodeLatexExporter
[E 14:04:59.427 NotebookApp] {
      "Accept-Language": "en-US,en;q=0.9", 
      "Accept-Encoding": "gzip, deflate, br", 
      "Sec-Fetch-Site": "same-origin", 
      "Host": "localhost:8889", 
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", 
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", 
      "Dnt": "1", 
      "Connection": "keep-alive", 
      "Referer": "http://localhost:8889/tree", 
      "Sec-Fetch-Mode": "navigate", 
      "Cookie": "_xsrf=2|64a9e87d|2c9ad6e009c8cc98d715c1e52c5936fe|1583346256; username-localhost-8888=\"2|1:0|10:1583795416|23:username-localhost-8888|44:MWE5MjAwNjIyNDg5NDAzNjg5NDMwNmE2ZGYxNTIzOTQ=|1a23742bb41a7c4840b565481bf2d313133f1eacc650ca145e88bf1e9e4ec3eb\"; username-localhost-8889=\"2|1:0|10:1585681492|23:username-localhost-8889|44:MmRiODY3YWMyMzQzNGVjNTlmOWZhZTFhMWI0N2IxZjA=|52a8dd5840fa56f910b2bc448dabe724e1db07af2f732982924507a3ebe2aa3e\"", 
      "Upgrade-Insecure-Requests": "1", 
      "Sec-Fetch-Dest": "document"
    }
[E 14:04:59.427 NotebookApp] 500 GET /notebooks/Untitled2.ipynb?kernel_name=python2 (::1) 216.25ms referer=http://localhost:8889/tree
kjkeefe commented 4 years ago

By the way, thank you for your work on this! I'm looking forward to having this working on my notebooks.

javierrodenas commented 4 years ago

Hi @kenjkeefe,

I am seeing that you are using python 2.7. It couldn't be adapted for this version but I'm not sure.

Could you update python version? I am using it with python 3.7 and it works perfectly.

Best regards.

kirbs- commented 4 years ago

I'm not entirely sure any versions after 0.5.2 work with Python 2.7. It was officially deprecated at the end of 2019. Try using 0.5.2 with pip install hide_code==0.5.2 --force-reinstall