파일을 직접 업로드 할 수 있으나, 하나씩 하기 귀찮다. 특히 대용량의 경우 더 귀찮다.
따라서 구글드라이브와 연동을 하고 싶다.
다음의 단계를 따라가면 된다.
1. 아래 코드를 코랩 노트북에서 실행하기
!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}
2. 실행하고 나면 링크와 secret_key를 입력하라는 칸이 나오는데, 링크 들어가서 로그인하고 진행해서~ 키를 받은뒤 칸에 넣는 것을 두 번 한다.
3. 아래의 코드를 실행하면 ./drive에 연동된 것을 알 수 있다.
!mkdir -p drive
!google-drive-ocamlfuse drive
참고: [링크]
'Server > Jupyter' 카테고리의 다른 글
Jupyter에 python3 커널 추가하기. (0) | 2018.04.02 |
---|