简体   繁体   English

如何解决 ModuleNotFoundError:没有名为“google.colab”的模块

[英]How to resolve ModuleNotFoundError: No module named 'google.colab'

When I run:当我运行时:

from google.colab import auth

I get this error:我收到此错误:

ModuleNotFoundError: No module named 'google.colab' ModuleNotFoundError:没有名为“google.colab”的模块

This module is required for accessing files on Google drive from python.从 python 访问 Google 驱动器上的文件需要此模块。 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) AFAIK,您可以从 colab.research.google.com 的笔记本环境中执行模块“google.colab”(它不是公开可用的包)

OFF-TOPIC: Looking at the tag conda in your question.题外话:查看您问题中的标签conda 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.请使用 PyDrive 从本地机器上的谷歌驱动器中读取。

References:参考:

  1. Google Colaboratory FAQ Google 合作实验室常见问题解答
  2. PyDrive PyDrive

If you want to run google-colab from your local machine and you want to install if via conda, just type the following:如果你想从本地机器上运行 google-colab 并且你想通过 conda 安装,只需输入以下内容:

conda install -c conda-forge google-colab

For reference: https://anaconda.org/conda-forge/google-colab供参考: https ://anaconda.org/conda-forge/google-colab

11 11

You can use !setup.py install to do that.您可以使用!setup.py install 来做到这一点。

Colab is just like a Jupyter notebook. Colab 就像一个 Jupyter 笔记本。 Therefore, we can use the !因此,我们可以使用 ! operator here to install any package in Colab.操作员在此处安装 Colab 中的任何软件包。 What !什么 ! actually does is, it tells the notebook cell that this line is not a Python code, its a command line script.实际上,它告诉笔记本单元这行不是 Python 代码,而是命令行脚本。 So, to run any command line script in Colab, just add a !因此,要在 Colab 中运行任何命令行脚本,只需添加一个 ! preceding the line.行前。

For example: !pip install tensorflow .例如: !pip install tensorflow This will treat that line (here pip install tensorflow) as a command prompt line and not some Python code.这会将该行(此处为 pip install tensorflow)视为命令提示行,而不是一些 Python 代码。 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).但请记住,在执行此操作之前,您必须将 setup.py 文件上传到您的驱动器(最好与笔记本所在的文件夹相同)。

Hope this answers your question希望这能回答你的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:Google Colab 上没有名为“nets”的模块 - ModuleNotFoundError: No module named 'nets' on Google Colab ModuleNotFoundError:Google Colab 中没有名为“pyaudio”的模块 - ModuleNotFoundError: No module named 'pyaudio' in Google Colab google.colab 模块中是否有 function 来关闭运行时 - Is there a function in google.colab module to close the runtime 在Google Colab中针对“注意ocr”修复“ ModuleNotFoundError:没有名为'fsns'的模块” - Fix “ModuleNotFoundError: No module named 'fsns'” in google colab for Attention ocr ModuleNotFoundError:没有名为“lanenet_model”的模块 - Google Colab - ModuleNotFoundError: No module named 'lanenet_model' - Google Colab Google Colab:ModuleNotFoundError:没有名为“base_positioner”的模块 - Google Colab : ModuleNotFoundError: No module named 'base_positioner' Google Colab ModuleNotFoundError:没有名为“sklearn.externals.joblib”的模块 - Google Colab ModuleNotFoundError: No module named 'sklearn.externals.joblib' 如何解决笔记本中的“ModuleNotFoundError: No module named 'package'”? - How to resolve "ModuleNotFoundError: No module named 'package'" in notebook? 如何解决 ModuleNotFoundError:没有名为“pandas”的模块 - How to resolve ModuleNotFoundError: No module named 'pandas' 如何解决“ ModuleNotFoundError”问题,没有名为“ XXXX”的模块 - How to resolve “ModuleNotFoundError” No module named 'XXXX'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM