Cannot install Google Colab locally

Viewed 5850

I have been unsucessfully trying to install google-colab on my computer (OS Windows).

The output I have when I run "pip install google-colab" is long but some of the errors that I receive are:

> Building wheel for pandas (setup.py) ... error   ERROR: Command
> errored out with exit status 1:    command:
> 'C:\Users\...\Anaconda3\python.exe' -u -c 'import sys, setuptools,
> tokenize; sys.argv[0] =
> '"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';
> __file__='"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';f=getattr(tokenize,
> '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
> bdist_wheel -d 'C:\Users\...\AppData\Local\Temp\pip-wheel-02i01qsx'

Then after a long error output, the end is:

 Rolling back uninstall of pandas
  Moving to c:\users\...\anaconda3\lib\site-packages\pandas-1.2.0.dist-info\
   from C:\Users\...\Anaconda3\Lib\site-packages\~andas-1.2.0.dist-info
  Moving to c:\users\...\anaconda3\lib\site-packages\pandas\
   from C:\Users\...\Anaconda3\Lib\site-packages\~-ndas
ERROR: Command errored out with exit status 1: 'C:\Users\...\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"'; __file__='"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\...\AppData\Local\Temp\pip-record-67jzzkdh\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\...\Anaconda3\Include\pandas' Check the logs for full command output.

Any hint or help would be highly appreciated.

2 Answers

From Colab's issues repo, Craig Citro (a software engineer on Google Colab) stated the following

There's no way to run the colab frontend locally.

To note, however, that Colaboratory lets you connect to a local runtime using Jupyter. This allows you to execute code on your local hardware and have access to your local file system (it's a Colab frontend with a local runtime). If that is your goal, here you can find a way to do that.

Setup instructions

In order to allow Colaboratory to connect to your locally running Jupyter server, you'll need to perform the following steps.

Step 1: Install Jupyter Install Jupyter on your local machine.

Step 2: Install and enable the jupyter_http_over_ws jupyter extension (one-time) The jupyter_http_over_ws extension is authored by the Colaboratory team and available on GitHub.

pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws

Step 3: Start server and authenticate

New notebook servers are started normally, though you will need to set a flag to explicitly trust WebSocket connections from the Colaboratory frontend.

jupyter notebook \
  --NotebookApp.allow_origin='https://colab.research.google.com' \
  --port=8888 \
  --NotebookApp.port_retries=0

Once the server has started, it will print a message with the initial backend URL used for authentication. Make a copy of this URL as you'll need to provide this in the next step. Step 4: Connect to the local runtime

In Colaboratory, click the "Connect" button and select "Connect to local runtime...". Enter the URL from the previous step in the dialog that appears and click the "Connect" button. After this, you should now be connected to your local runtime.

It sounds like what you are trying to do is to run Google Colab on a local server and to have that local server be able to query your Google Drive just like it does in the hosted interface. The top answer resolves the first part of your question: you don't need the google-colab pip library to simply host locally. Having the locally hosted session work with your Google Drive is a different, more complicated matter. Referring to the answer to a similar question here: How to resolve ModuleNotFoundError: No module named 'google.colab'

I have verified that simply following the instructions from other answers does not solve the issues of making calls to the google.drive API in colab.

It looks like there is something wrong with installing the google-colab pip library inside a conda environment you intend to use to locally run colab.

I do not know what the cause is, nor how to report it, but the answer threads from the link above mentions two possible solutions to this problem:

  1. Use conda install -c conda-forge google-colab to install google-colab. I know Google often says not to use conda-forge for its packages, and for me this gave the error KeyError: CLOUDSDK_CONFIG, but for others it has worked
  2. Using PyDrive2. I have not verified this, but it is an actively maintained wrapper for the Google API and has both pip and conda install hooks
Related