AWS在线开发端点抛出导入错误,没有名为awsglue.transforms的模块

Shi*_*ary 3 amazon-web-services aws-glue

我正在尝试使用 python 在 AWSglue 中运行 ETL 作业,脚本是

import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job

glueContext = GlueContext(SparkContext.getOrCreate())

person = glueContext.create_dynamic_frame.from_catalog(
           database="test",
           table_name="testetl_person")

person.printSchema()

Run Code Online (Sandbox Code Playgroud)

此脚本正在 AWS 开发端点中运行,并且在运行作业时会引发以下异常

File "/tmp/runscript.py", line 118, in <module>
runpy.run_path(temp_file_path, run_name='__main__')
File "/usr/local/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/local/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/glue-python-scripts-cf4xyag5/test.py", line 2, in <module>
ModuleNotFoundError: No module named 'awsglue.transforms'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/tmp/runscript.py", line 137, in <module>
raise e_type(e_value).with_tracsback(new_stack)
AttributeError: 'ModuleNotFoundError' object has no attribute 'with_tracsback'
Run Code Online (Sandbox Code Playgroud)

谁能帮我吗?如果您需要更多信息,请告诉我。

Lam*_*nus 8

根据This,你运行代码的语言应该设置为spark,而不是python。

  • 大家好,你们在哪里可以找到 Spark/Python 设置“运行代码的语言”?我尝试在 IntelliJ 中运行 python 脚本时遇到同样的问题 `from awsglue.utils import getResolvedOptions \ ModuleNotFoundError: No module named 'awsglue'` (4认同)