When I run:
from google.colab import auth
I get this error:
ModuleNotFoundError: No module named 'google.colab'
This module is required for accessing files on Google drive from python. How can I resolve this error?
您可以简单地下载google-colab并在本地使用它。
pip install google-colab
AFAIK, you can execute the module 'google.colab' from within the notebook environment of colab.research.google.com (it is not a publicly available package)
OFF-TOPIC: Looking at the tag conda
in your question. I assume that you are running the code from your local machine. Please make use of PyDrive to read from google drive on your local machine.
References:
If you want to run google-colab from your local machine and you want to install if via conda, just type the following:
conda install -c conda-forge google-colab
For reference: https://anaconda.org/conda-forge/google-colab
11
You can use !setup.py
install to do that.
Colab is just like a Jupyter notebook. Therefore, we can use the ! operator here to install any package in Colab. What ! actually does is, it tells the notebook cell that this line is not a Python code, its a command line script. So, to run any command line script in Colab, just add a ! preceding the line.
For example: !pip install tensorflow
. This will treat that line (here pip install tensorflow) as a command prompt line and not some Python code. However, if you do this without adding the ! preceding the line, it'll throw up an error saying "invalid syntax".
But keep in mind that you'll have to upload the setup.py file to your drive before doing this (preferably into the same folder where your notebook is).
Hope this answers your question
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.