문제 설명
Google Cloud 자연어 가져오기 오류 (Google Cloud Natural Language Import Error)
Google Cloud Natural Language API를 실행하는 데 많은 문제가 있습니다. Google VM의 Linux에서 Python 프로그램을 실행하려고 합니다. 또한 오류의 전체 역추적을 실행하는 방법을 잘 모르겠습니다. 다음 코드는 작동하지 않습니다.
google.cloud에서 가져오기 언어 google.cloud.language에서 가져오기 google.cloud.language에서 열거형 가져오기
.
Python 2에서 다음 오류가 발생합니다.
Traceback(최근 호출 마지막): File "natlangex.py", line 3, in from google.cloud.language import enums ImportError: cannot import name enums
Python 3으로 업그레이드를 시도했는데 Python 3을 실행할 때 오류가 발생합니다. 그리고 Python 3으로 업데이트했습니다. 한 가지 혼란스러운 점은 Python 3을 실행할 때 오류가 약간 다르다는 것입니다.
Traceback(최근 호출 마지막): File "natlangex.py", line 2, in <모듈> from google.cloud 가져오기 언어 ImportError: 'google'이라는 모듈이 없습니다.
제가 시도한 다른 작업은 다음과 같습니다.
- SDK를 설치했습니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
을 설정했습니다.!pip install google‑cloud‑language
를 시도했습니다. li>- pip
pip install ‑‑upgrade setuptools pip를 업그레이드했습니다.
정말 길을 잃었습니다! 미리 감사드립니다.
/p>추적(가장 최근 호출 마지막): 파일 "natlangex.py", 줄 2, from google.cloud 가져오기 언어 ImportError: 'google'이라는 모듈이 없습니다.
제가 시도한 다른 작업은 다음과 같습니다.
- SDK를 설치했습니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
을 설정했습니다.!pip install google‑cloud‑language
를 시도했습니다. li>- pip
pip install ‑‑upgrade setuptools pip를 업그레이드했습니다.
정말 길을 잃었습니다! 미리 감사드립니다.
/p>추적(가장 최근 호출 마지막): 파일 "natlangex.py", 줄 2, from google.cloud 가져오기 언어 ImportError: 'google'이라는 모듈이 없습니다.
제가 시도한 다른 작업은 다음과 같습니다.
- SDK를 설치했습니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
을 설정했습니다.!pip install google‑cloud‑language
를 시도했습니다. li>- pip
pip install ‑‑upgrade setuptools pip를 업그레이드했습니다.
정말 길을 잃었습니다! 미리 감사드립니다.
from google.cloud 가져오기 언어 ImportError: 'google'이라는 모듈이 없습니다.제가 시도한 다른 작업은 다음과 같습니다.
- SDK를 설치했습니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
을 설정했습니다.!pip install google‑cloud‑language
를 시도했습니다. li>- pip
pip install ‑‑upgrade setuptools pip를 업그레이드했습니다.
정말 길을 잃었습니다! 미리 감사드립니다.
from google.cloud import language ImportError: 'google'이라는 이름의 모듈이 없습니다.제가 시도한 다른 방법은 다음과 같습니다.
- SDK를 설치했습니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
을 설정했습니다.!pip install google‑cloud‑language
를 시도했습니다. li>- pip
pip install ‑‑upgrade setuptools pip를 업그레이드했습니다.
정말 길을 잃었습니다! 미리 감사드립니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json".!pip install google‑cloud‑language
를 업그레이드했습니다. pip install ‑‑upgrade setuptools pip.
정말 길을 잃었습니다! 미리 감사드립니다.
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json".!pip install google‑cloud‑language
를 업그레이드했습니다. pip install ‑‑upgrade setuptools pip.
정말 길을 잃었습니다! 미리 감사드립니다.
참조 솔루션
방법 1:
It seems that you are using wrong syntax because of the library update, you may refer now to the new one, following [1] and more specifically [2].
It seems that the official Natural Language documentation of Google Cloud is not updated yet [3], but at the end of this documentation you have links to the Python Client Library [1][2] where it explains the changes.
Your imports should be:
from google.cloud import language_v1
from google.cloud.language_v1 import enums
from google.cloud.language_v1 import types
[1] https://googleapis.dev/python/language/latest/api.html
[2] https://googleapis.dev/python/language/latest/gapic/v1/api.html
[3] https://cloud.google.com/natural‑language/docs/reference/libraries#client‑libraries‑usage‑python