I tried to mount my drive in Google Colab, but, I can't do it because of credential error.
I want to mount another drive different from the one I am using in Google Colab.
The following is my commands.
from google.colab import drive
drive.mount('/content/drive')
The following is the part of question.
MessageError Traceback (most recent call last)
<ipython-input-1-d5df0069828e> in <module>()
1 from google.colab import drive
----> 2 drive.mount('/content/drive')
3 frames
/usr/local/lib/python3.7/dist-packages/google/colab/drive.py in mount(mountpoint,
force_remount, timeout_ms, use_metadata_server)
111 timeout_ms=timeout_ms,
112 use_metadata_server=use_metadata_server,
--> 113 ephemeral=ephemeral)
114
115
/usr/local/lib/python3.7/dist-packages/google/colab/drive.py in _mount(mountpoint,
force_remount, timeout_ms, use_metadata_server, ephemeral)
134 if ephemeral:
135 _message.blocking_request(
--> 136 'request_auth', request={'authType': 'dfs_ephemeral'}, timeout_sec=None)
137
138 mountpoint = _os.path.expanduser(mountpoint)
/usr/local/lib/python3.7/dist-packages/google/colab/_message.py in
blocking_request(request_type, request, timeout_sec, parent)
173 request_id = send_request(
174 request_type, request, parent=parent, expect_reply=True)
--> 175 return read_reply_from_input(request_id, timeout_sec)
/usr/local/lib/python3.7/dist-packages/google/colab/_message.py in
read_reply_from_input(message_id, timeout_sec)
104 reply.get('colab_msg_id') == message_id):
105 if 'error' in reply:
--> 106 raise MessageError(reply['error'])
107 return reply.get('data', None)
108
MessageError: Error: credential propagation was unsuccessful
I could mount another drive yesterday to do the same method.
What is the solution?
I solved this problem with this link. The following is the correct code:
from google.colab import drive
drive._mount('/content/drive')
Here is the screenshot of the code:
As of now (26th January 2022), you can not mount another drive with different goggle account in Colab with drive.mount() or drive._mount(). Previously it could be done.
Now, You may use gdrive package instead. Check my detailed answer in this thread
Update: From Mars 30, 2022, my old solution isn't working! I find another solution (Phillip's solution) that is working now.
Phillip's Solution:
This solution is based on Phillip's post. You can follow his post for more information.
Follow these steps:
!sudo add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!sudo apt-get update -qq 2>&1 > /dev/null
!sudo apt -y install -qq google-drive-ocamlfuse 2>&1 > /dev/null
!google-drive-ocamlfuse
Failure("Error opening URL:https://accounts.google.com/o/oauth2/auth?client_id=... ")
!sudo apt-get install -qq w3m # to act as web browser
!xdg-settings set default-web-browser w3m.desktop # to set default browser
%cd /content
!mkdir drive
%cd drive
!mkdir MyDrive
%cd ..
%cd ..
!google-drive-ocamlfuse /content/drive/MyDrive
You must get this message:
Access token retrieved correctly.
My Old Solution
!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}
%cd /content
!mkdir drive
%cd drive
!mkdir MyDrive
%cd ..
%cd ..
!google-drive-ocamlfuse /content/drive/MyDrive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With