오늘 제가 로컬로 실행중인 GCS와 상호 작용하는 코드를 테스트하고 싶었습니다.구글 클라우드 libs가 Colaboratory에서 작동하지 않습니다.
- 이 Colaboratory의 '지역'/ tmp를
!export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>
storage_client = storage.Client('my-project')
에- 다운로드에게 G 드라이브에이를 서비스 계정 JSON 파일을 저장하고 다른 방법/속성 재생 : 내 계획이다.
나는 !pip install --upgrade google-cloud
를 설치하지만, 총알 4 (인증 오류를 기대)을 테스트 할 때, 나는 의존성 문제를 다시 메시지를 얻을 :
ContextualVersionConflictTraceback (most recent call last)
<ipython-input-13-7346ac058842> in <module>()
----> 1 from google.cloud import storage
2
3
4 # Authenticate to GCS.
5 from google.colab import auth
/usr/local/lib/python2.7/dist-packages/google/cloud/storage/__init__.py in <module>()
33
34 from pkg_resources import get_distribution
---> 35 __version__ = get_distribution('google-cloud-storage').version
36
37 from google.cloud.storage.batch import Batch
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.pyc in get_distribution(dist)
554 dist = Requirement.parse(dist)
555 if isinstance(dist, Requirement):
--> 556 dist = get_provider(dist)
557 if not isinstance(dist, Distribution):
558 raise TypeError("Expected string, Requirement, or Distribution", dist)
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.pyc in get_provider(moduleOrReq)
428 """Return an IResourceProvider for the named module or requirement"""
429 if isinstance(moduleOrReq, Requirement):
--> 430 return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
431 try:
432 module = sys.modules[moduleOrReq]
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.pyc in require(self, *requirements)
970 included, even if they were already activated in this working set.
971 """
--> 972 needed = self.resolve(parse_requirements(requirements))
973
974 for dist in needed:
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.pyc in resolve(self, requirements, env, installer, replace_conflicting, extras)
861 # Oops, the "best" so far conflicts with a dependency
862 dependent_req = required_by[req]
--> 863 raise VersionConflict(dist, req).with_context(dependent_req)
864
865 # push the new requirements onto the stack
ContextualVersionConflict: (google-cloud-core 0.27.1 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('google-cloud-core<0.29dev,>=0.28.0'), set(['google-cloud-storage']))
내가 Datalab에서 시도하지 않은하지만 Colaboratory이 훨씬 더 편리합니다.
하위 집합 로딩이 모든 것을 설명 : 나는 구글에서 ''수입 google.cloud'을하지만 수 없었다. 클라우드 가져 오기 저장소'. 따라서 최신 정보를 얻으려는 생각. 시작시 해결 방법 접수 및 테스트하지만, 전체 패키지는 참으로 가장 좋은 것입니다 –