Installing Autopep8 extension

Hello,

I would like to enable certain nbextensions in my Jupyter Notebooks, for example the Autopep8 extension.

I tried to follow the documentation on this page: Install and enable notebook extensions - Help

I executed the following command jupyter nbextension enable Autopep8, but it says the module could not be found.

So I assumed the extension is not available, so I followed the section on how to enable extension that is not provided by SWAN:

pip install --user Autopep8
export JUPYTER_DATA_DIR=$CERNBOX_HOME/.local/share/jupyter
jupyter nbextension install --py --symlink --user Autopep8
jupyter nbextension enable Autopep8 --user --py

Unfortunately, an exception is thrown upon the execution of the third command:

Traceback (most recent call last):
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/bin/jupyter-nbextension", line 33, in <module>
    sys.exit(load_entry_point('notebook==6.4.0', 'console_scripts', 'jupyter-nbextension')())
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/jupyter_core/application.py", line 254, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/traitlets/config/application.py", line 845, in launch_instance
    app.start()
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/notebook/nbextensions.py", line 980, in start
    super().start()
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/jupyter_core/application.py", line 243, in start
    self.subapp.start()
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/notebook/nbextensions.py", line 708, in start
    self.install_extensions()
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/notebook/nbextensions.py", line 679, in install_extensions
    full_dests = install(self.extra_args[0],
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/notebook/nbextensions.py", line 203, in install_nbextension_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
    m = import_item(module)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_102b_swan/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 38, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'Autopep8'

What might be the problem here? Thanks for your help.

Ladislav

Dear Ladislav,

Autopep8 is pre-installed but not enabled. You can enable it from the UI.

  • Click on the menu from the page after starting your session (three dots on top right) and click “Nbextensions configuration”
  • Untick “disable configuration for nbextensions without explicit compatibility”
  • Tick and enable autopep8 extension
  • Reload any notebook pages

Does this work for you?

Regards
Krishnan