E: Unable to locate package google-drive-ocamlfuse解决办法

最近一周在使用colab 挂载Google drive运行 机器学习代码时突然出现了下面的问题,进入colab环境按照免费使用谷歌的深度学习云服务教程输入下面的配置认证指令:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

运行之后结果出现下面的错误信息(关键部分):

Warning: apt-key output should not be parsed (stdout is not a terminal)
E: Unable to locate package google-drive-ocamlfuse
··········
/bin/bash: google-drive-ocamlfuse: command not found

去GitHub上面搜索之后发现很多人也都遇到过这个问题,但是他们使用的解决办法多为更改路径;比如讨论最多的solution是

Solution:

from google.colab import drive
drive.mount('/content/drive')
For example,If you want to find your file:

import os
os.chdir("drive/My Drive/Colab/AIC")

我在使用之后发现并不能解决现在遇到的问题。

后来终于在GitHub上面找到一个新的解决方案,只需要更新下配置认证指令就可以解决问题了。新的配置认证指令如下:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
#!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
#!apt-get update -qq 2>&1 > /dev/null
#!apt-get -y install -qq google-drive-ocamlfuse fuse
!wget https://launchpad.net/~alessandro-strada/+archive/ubuntu/google-drive-ocamlfuse-beta/+build/15331130/+files/google-drive-ocamlfuse_0.7.0-0ubuntu1_amd64.deb
!dpkg -i google-drive-ocamlfuse_0.7.0-0ubuntu1_amd64.deb
!apt-get install -f
!apt-get -y install -qq fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

这样,困扰近一个周的Unable to locate package google-drive-ocamlfuse 的问题就解决了。

顺便说下,Google这次除了提供免费的K80GPU,竟然还新增了TPU。有图有真相E: Unable to locate package google-drive-ocamlfuse解决办法_第1张图片

你可能感兴趣的:(E: Unable to locate package google-drive-ocamlfuse解决办法)