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

后端 未结 3 975
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 06:40

I want to run the command:

from google.colab import auth

But I am getting this error:

ModuleNotFoundError: No module nam

3条回答
  •  Happy的楠姐
    2021-02-20 07:16

    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

提交回复
热议问题