apache/beam · error · ImportError
Google Cloud Natural Language API not supported for this…
Error message
Google Cloud Natural Language API not supported for this execution environment (could not import Natural Language API client).
What it means
Module-level guard in naturallanguageml.py: importing the Google Cloud Natural Language client library failed, so none of the module's transforms can run in this environment. The error fires at import time, before any pipeline code executes.
Solutions
- Install the extra: pip install 'apache_beam[gcp]'
- Or install the client directly: pip install google-cloud-language
- Verify the install with: python -c 'from google.cloud import language_v1'
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at sdks/python/apache_beam/ml/gcp/naturallanguageml.py:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/ccf5e5b1b7534090.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/gcp/naturallanguageml.py:30
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Union
import apache_beam as beam
from apache_beam.metrics import Metrics
try:
from google.cloud import language
from google.cloud import language_v1
except ImportError:
raise ImportError(
'Google Cloud Natural Language API not supported for this execution '
'environment (could not import Natural Language API client).')
__all__ = ['Document', 'AnnotateText']
class Document(object):
"""Represents the input to :class:`AnnotateText` transform.
Args:
content (str): The content of the input or the Google Cloud Storage URI
where the file is stored.
type (`Union[str, google.cloud.language_v1.Document.Type]`): Text type.
Possible values are `HTML`, `PLAIN_TEXT`. The default value is
`PLAIN_TEXT`.
language_hint (`Optional[str]`): The language of the text. If not specified,
language will be automatically detected. Values should conform to
ISO-639-1 standard.View on GitHub (pinned to 12126d8942)