FApps has been introduced in the Graduate School of Frontier Sciences, the University of Tokyo. I was considering how to access data on the shared drive (formerly called team drive) of G Suite from a local Python code on Windows 10 Pro using PyDrive. However, it ended in failure. In addition, uninstalling PyDrive installed with conda also failed. Recently, I learned that there is a way to mount Google shared drive locally with Google Drive File Stream as a way to access the data on the shared drive.
Google drive file stream
Login with your FApps account and open Google Drive. There are My Drive and Shared Drive. Mounting them locally does not copy files locally (there may be a way to sync), so it barely uses the disk space on the local PC.
Click on the settings icon; click on "Download desktop drive"; follow the instructions to install it as a Windows application (there is also MAC version).
Mounting as Windows G-drive
When the installation was successful, the Windows G drive (Google Drive File Stream) appears; the folders of My Drive and the shared drive exist in it. Looking at each folder, the same folders and files in Google Drive certainly existed. It may take time to access large files.
Accessing files on Google drive from a local Python script
Access locally mounted Google Drive files from a local Python script. A text file
test_google_drive.txt was prepared in My Drive and Shared Drive of Google Drive; accessing them from a local Python code in Jupyter Notebook.
f1path = "G:/マイドライブ/test_google_drive.txt" with open(f1path) as f: s = f.read() print(type(s)) print(s) f2path = "G:/共有/Jun Sasaki/test_google_drive.txt" with open(f2path) as f: s = f.read() print(type(s)) print(s)
The following result was obtained for both of the above file handling.
<class 'str'> Hello World1 Second line EOF
It is very easy and convenient to access Google Drive files from a local Python script on Windows!