Reputation: 196
Until yesterday (20 Jan) I could connect to another google drive account (using drive._mount), but when I tried this today, google colab showed me this error:
from google.colab import drive
drive._mount('/content/drive/')
/usr/local/lib/python3.7/dist-packages/google/colab/drive.py in _mount(mountpoint, force_remount, timeout_ms, use_metadata_server, ephemeral)
294 wrote_to_fifo = True
295 elif case == 5 and not use_metadata_server:
--> 296 raise ValueError('mount failed: invalid oauth code')
297 elif case == 6:
298 # Terminate the DriveFS binary before killing bash.
ValueError: mount failed: invalid oauth code
Strange thing is that error tells me "invalid oauth code", but not let me connect to google page and copy the code!
And I set use_metadata_server=True but this time, new error appeares:
from google.colab import drive
drive._mount('/content/drive/', use_metadata_server=True)
ValueError Traceback (most recent call last)
<ipython-input-5-42a561ce7057> in <module>()
1 from google.colab import drive
----> 2 drive._mount('/content/drive/', use_metadata_server=True)
/usr/local/lib/python3.7/dist-packages/google/colab/drive.py in _mount(mountpoint, force_remount, timeout_ms, use_metadata_server, ephemeral)
285 ': timeout during initial read of root folder; for more info: '
286 'https://research.google.com/colaboratory/faq.html#drive-timeout')
--> 287 raise ValueError('mount failed' + extra_reason)
288 elif case == 2:
289 # Not already authorized, so do the authorization dance.
ValueError: mount failed
Also I used drive.mount but showed pop-up and ask me to enter another account credentials. When I enter it, this error appears:
from google.colab import drive
drive.mount('/content/drive/')
MessageError Traceback (most recent call last)
<ipython-input-1-91874b305a32> in <module>()
1 from google.colab import drive
----> 2 drive.mount('/content/drive/')
3 frames
/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 think this is new policy. Is there an solution?
Upvotes: 13
Views: 22823
Reputation: 31
A very simple solution worked for me hope it helps you:
simply change the dir to mount drive (example ==> drive to gdrive)
use force_remount
property:
drive.mount('/content/gdrive', force_remount=True)
Upvotes: 0
Reputation: 1
By selecting all the features that Google Drive for desktop can access, it will work.
Upvotes: 0
Reputation: 143
Like it or not for now we can not mount another drive from colab. So forget drive._mount as it is not working (._mount)
SO the only solution that is working is to copy your folder from your other drive to your current drive (The account you are login in to in the colab) and use drive.mount (and not drive._mount)
OR
just login into colab with your account that has the folder/directory you want to mount to in your drive
Upvotes: 0
Reputation: 399
As @user1086010 mentioned this feature has been removed. I am using "gdrive" package instead. Run the following notebook code block for installing gdrive packhage
import os
com_wget = "sudo wget " +"https://github.com/prasmussen/gdrive/releases/download/2.1.1/gdrive_2.1.1_linux_386.tar.gz"
com_unzip = "sudo tar -xzf gdrive_2.1.1_linux_386.tar.gz"
com_permission = "sudo chmod +x gdrive"
com_install_executor = "sudo install gdrive /usr/local/bin/gdrive"
os.system(com_wget)
os.system(com_unzip)
os.system(com_permission)
os.system(com_install_executor)
then connect your drive with "gdrive list":
!sudo gdrive list
You can download your files with:
!gdrive download <gdrive_file_id>
you can upload with:
!gdrive upload <path_to_file>
or for directory:
!gdrive upload -r <path_to_dir>
You can upload a file to a specific gdrive folder using:
!gdrive upload --parent <gdrive_folder_id> <path_to_file>
For removing the authentication token run the following command:
!rm -rf ~/.gdrive/token_*.json
Check this link for reference use cases and documentation of the package: gdrive package link
Upvotes: 3
Reputation: 1
I can't upload or download files from my gdrive to my colab (same account, worked 48 hours ago).
Underscore or not.
Yes, if you share a file to anyone on the internet and use !gdown you can load a file from your gdrive to colab but good luck saving it on your gdrive after.
Pydrive only lets you upload tiny kiddie files.
You had never guessed the world's biggest IT company could be behind his kindergarden show.
Sad that they are too big to fail. They got no real competition.
Upvotes: 0
Reputation: 697
this feature has been removed, you can now only mount a google drive from the same account of your notebook. https://github.com/googlecolab/colabtools/issues/2562#issuecomment-1017869732
Upvotes: 9
Reputation: 141
for the moment the only solution that is working right now isrom this similar question but two months ago:
!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
Let's hope for the normal way drive.mount
to be fixed soon!
Upvotes: 7
Reputation: 196
Alright, until this problem get solved, I did this trick for my project:
I shared which files I need (like datasets) with my other accounts. For this, you should:
Upvotes: 1