Coder Social home page Coder Social logo

Comments (8)

kirbs- avatar kirbs- commented on July 29, 2024

Would you post which version of nbconvert and hide_code you're using?

from hide_code.

boundino avatar boundino commented on July 29, 2024

Thanks for the prompt reply!
I'm using nbconvert 6.0.6 and hide_code 0.5.5.

from hide_code.

kirbs- avatar kirbs- commented on July 29, 2024

It looks like hide_code isn't fully installed. Can you run jupyter nbextension list and jupyter serverextension list then post the output of each?

from hide_code.

kirbs- avatar kirbs- commented on July 29, 2024

Also might be an issue with nbconvert 6.x. This was release a couple of weeks ago and I haven't tested hide_code against it yet.

from hide_code.

boundino avatar boundino commented on July 29, 2024

Yes, please find the output below

xjjgww:~ xjjgwws-MacBook-Air:~
() xjjgww/ ⁄(⁄⁄•⁄ω⁄•⁄⁄)⁄$ jupyter nbextension list
Known nbextensions:
  config dir: /Users/xjjgww/.jupyter/nbconfig
    notebook section
      hide_code/hide_code  enabled
      - Validating: OK
  config dir: /usr/local/etc/jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled
      - Validating: OK
xjjgww:~ xjjgwws-MacBook-Air:~
() xjjgww/ ⁄(⁄⁄•⁄ω⁄•⁄⁄)⁄$ jupyter serverextension list
config dir: /Users/xjjgww/.jupyter
    hide_code  enabled
    - Validating...
      hide_code  OK
config dir: /usr/local/etc/jupyter
    jupyterlab  enabled
    - Validating...
      jupyterlab 2.2.8 OK

from hide_code.

kirbs- avatar kirbs- commented on July 29, 2024

Just noticed nbconvert 6.X may have broke this extension.

template_path has become template_paths. If referring to a 5.x style .tpl template use the full path with the template_file argument to the file. On the command line the pattern is --template-file=<path/to/file.tpl>.

Try downgrading to nbconvert 5.x until I can get hide_code updated.

from hide_code.

boundino avatar boundino commented on July 29, 2024

Many thanks for figuring this out!
I tried nbconvert 5.5 and 5.6 (uninstall 6.x and install 5.x). jupyter nbconvert --to html works but jupyter nbconvert --to hide_code_html threw

traitlets.traitlets.TraitError: 'template_path' is not a trait of 'HideCodeHTMLExporter' instances

The detailed output is as

[NbConvertApp] Converting notebook LIGOtutorialJLab.ipynb to hide_code_html
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'template_path'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbconvert", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/traitlets/config/application.py", line 837, in launch_instance
    app.start()
  File "/usr/local/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "/usr/local/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 510, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 481, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 94, in from_notebook_node
    self.register_filter('highlight_code', highlight_code)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 383, in register_filter
    return self._register_filter(self.environment, name, jinja_filter)
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 126, in environment
    self._environment_cached = self._create_environment()
  File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 411, in _create_environment
    additional_paths + \
  File "/usr/local/lib/python3.7/site-packages/hide_code/hide_code_html_exporter.py", line 27, in template_path
    return super(HideCodeHTMLExporter, self).template_path + [os.path.join(os.path.dirname(__file__), "Templates")]
  File "/usr/local/lib/python3.7/site-packages/traitlets/traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "/usr/local/lib/python3.7/site-packages/traitlets/traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "/usr/local/lib/python3.7/site-packages/traitlets/traitlets.py", line 1574, in trait_defaults
    "instances" % (n, type(self).__name__))
traitlets.traitlets.TraitError: 'template_path' is not a trait of 'HideCodeHTMLExporter' instances

Any idea why this happened? Thank you!

from hide_code.

kirbs- avatar kirbs- commented on July 29, 2024

After some more digging nbconvert 6.0 also forces traitlets to upgrade from 4.x to 5.x. Would you try also downgrading to traitlets==4.3.3. This worked for me on a fresh virtualenv with Python 3.8.

Here's the output of jupyter --version

jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : 4.7.7
ipython          : 7.18.1
ipykernel        : 5.3.4
jupyter client   : 6.1.7
jupyter lab      : not installed
nbconvert        : 5.4.1
ipywidgets       : 7.5.1
nbformat         : 5.0.7
traitlets        : 4.3.3

from hide_code.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.