googledatalab / pydatalab

Google Datalab Library
Apache License 2.0
194 stars 79 forks source link

Issue installing datalab jupyter extension #691

Open bigbitbus opened 6 years ago

bigbitbus commented 6 years ago

Hello,

I am trying to install the jupyter extension based on the instructions in the README file; the installation works, but running the "enable" command is failing with the error trace shown below. What may I be missing?

Installing /root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/datalab/notebook/static -> gcpdatalab
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/visualization.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/bigquery.css
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/job.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/parcoords.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/charting.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/charting.css
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/bigquery.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/element.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/job.css
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/style.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/extern/d3.parcoords.css
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/extern/sylvester.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/extern/d3.parcoords.js
Up to date: /root/.virtualenvs/jupy2/share/jupyter/nbextensions/gcpdatalab/extern/lantern-browser.html
- Validating: OK

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable datalab.notebook --py --sys-prefix

(jupy2) root@udtp:~/bigbitbus/learnml/training-data-analyst/courses/machine_learning/deepdive/03_tensorflow# jupyter nbextension enable datalab.notebook --py --sys-prefix
Traceback (most recent call last):
  File "/root/.virtualenvs/jupy2/bin/jupyter-nbextension", line 11, in <module>
    sys.exit(main())
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/notebook/nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/notebook/nbextensions.py", line 896, in start
    self.toggle_nbextension_python(self.extra_args[0])
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/notebook/nbextensions.py", line 872, in toggle_nbextension_python
    logger=self.log)
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/notebook/nbextensions.py", line 483, in enable_nbextension_python
    logger=logger)
  File "/root/.virtualenvs/jupy2/local/lib/python2.7/site-packages/notebook/nbextensions.py", line 386, in _set_nbextension_state_python
    for nbext in nbexts]
KeyError: 'require'
(jupy2) root@udtp:~/bigbitbus/learnml/training-data-analyst/courses/machine_learning/deepdive/03_tensorflow# jupyter --version
4.4.0
(jupy2) root@udtp:~/bigbitbus/learnml/training-data-analyst/courses/machine_learning/deepdive/03_tensorflow# pip freeze | grep datalab
datalab==1.1.3
laughedelic commented 5 years ago

I have the same problem trying to run in in Google Colab.

blois commented 5 years ago

For Colab it should be sufficient to just do

!jupyter nbextension install datalab.notebook

But that should not be needed to use the Python code.

laughedelic commented 5 years ago

@blois if I run this command without --py option, I get a No such file or directory: u'datalab.notebook' error. If I run it with --py I get the same message as the OP posted, saying that I have to enable this extension and then I run

!jupyter nbextension enable datalab.notebook --py

and get the same KeyError: 'require' error.

Here is an example notebook: https://colab.research.google.com/drive/1Vii3jmQq2uqnmqS1DBvuY2qky28fzRKi

blois commented 5 years ago

Colab does not load nbextensions at startup so nbextension enable will have no effect there.

Is there something in particular that you are trying to do?

laughedelic commented 5 years ago

I'm just trying to load the datalab extension/library to use the %%bq magic.

Is it possible to use this pydatalab library in Jupyter in general and in Colab in particular without all the special Datalab runtime? (I'm new to all this stuff, so I wouldn't be surprised if my question doesn't make sense)

blois commented 5 years ago

An alternative is to use the %%bigquery magic from google.cloud.bigquery.

This will work in Jupyter and Colab.

An example in Colab is https://colab.research.google.com/notebooks/bigquery.ipynb

laughedelic commented 5 years ago

Well, thanks, but this thing is very primitive compared to the %%bq from datalab. The main feature I miss is creating named queries with subqueries dependencies.

QuinRiva commented 5 years ago

Well, thanks, but this thing is very primitive compared to the %%bq from datalab. The main feature I miss is creating named queries with subqueries dependencies.

Agree, whilst the google.cloud.bigquery library has some advantages, the magics are substantially inferior.