tnc-br / ddf-isoscapes

4 stars 0 forks source link

Fix: No module named 'google.colab' #39

Closed jmogarrio closed 1 year ago

jmogarrio commented 1 year ago
ModuleNotFoundError                       Traceback (most recent call last)
Cell In [8], line 3
      1 # Access data stored on Google Drive
      2 if GDRIVE_BASE:
----> 3     from google.colab import drive
      4     drive.mount(GDRIVE_BASE)

ModuleNotFoundError: No module named 'google.colab'
jmogarrio commented 1 year ago

Online searches suggested that the solution was to simply run %pip install google-colab, but I've run into the following issue (adding the --use-pep517, both just to the google-colab installation command and in addition to the other commands doesn't fix the issue).

Collecting google-colab
  Using cached google_colab-1.0.0-py2.py3-none-any.whl
Collecting notebook~=5.2.0
  Using cached notebook-5.2.2-py2.py3-none-any.whl (8.0 MB)
Collecting pandas~=0.24.0
  Using cached pandas-0.24.2.tar.gz (11.8 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      /usr/local/google/home/jmogarrio/.local/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      error in pandas setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected end or semicolon (after version specifier)
          pytz >= 2011k
               ~~~~~~~^
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

I was gettin different errors earlier and had to reinstall tornado to run a local Jupyter server because the google-colab installation reverted it to a previous version not compatible with Jupyter.

No sure how long this could take to fix or how others have remedied this issue (will check), but in the meantime have filed #43 (which is a valuable feature anyway).

jmogarrio commented 1 year ago

According to Ruben this is an issue with local runtimes, google.colab is only available in hosted runtimes.

One way to deal with this is to have different imports for local and hosted runtimes, which can be determined either manually or automatically. Might also be worth filing an issue against Colab to see if they can make google.colab imports available in local runtimes.

benwulfe commented 1 year ago

duplicate with issue around getting both environments to work. closing out for now.

jmogarrio commented 1 year ago

This isn't a duplicate, this is a specific task that's needed for the runtimes to work, part of the breakdown of getting both environments to work. Reopening.

This is solved for hosted runtimes but an open problem for local runtimes. The alternative mentioned in the description is the most straightforward but not necessarily feasible. The more elaborate workaround is to provide access via the GDrive python API.

benwulfe commented 1 year ago

the last fix here is to catch the exception in the call to mount gdrive and to print a very clear warning that we assume you are local when that happens.