为什么在本地机器上 运行 apache beam 时显示属性错误?
Why does it say attribute error while running apache beam on local machine?
我正尝试在本地计算机上使用 Python SDK 运行 apache beam 程序。我创建并激活了 python 虚拟环境,还使用 pip 安装了 apache beam。
但是,当我使用以下命令触发代码时,它会给出 attribute error
并显示:
module filename.py has no attribute __path__
下面是我 运行 的命令(通过转到 venv
文件夹):
python -m filename.py
请帮我解决这个问题。我正在尝试学习 apache beam
import apache_beam as beam
p=beam.Pipeline()
lines= p | beam.io.ReadFromText('path\My_sample_input_file.txt');
lines | beam.io.WriteToText('path\output2.txt')
您不应将 -m
标志用于 运行 脚本。参见 What is the purpose of the -m switch?
到运行一个python脚本:
python myfile.py
导入并运行一个模块:
python -m myfile
这也有效,因为当前工作目录位于 python 个模块的搜索路径中。
我正尝试在本地计算机上使用 Python SDK 运行 apache beam 程序。我创建并激活了 python 虚拟环境,还使用 pip 安装了 apache beam。
但是,当我使用以下命令触发代码时,它会给出 attribute error
并显示:
module filename.py has no attribute __path__
下面是我 运行 的命令(通过转到 venv
文件夹):
python -m filename.py
请帮我解决这个问题。我正在尝试学习 apache beam
import apache_beam as beam
p=beam.Pipeline()
lines= p | beam.io.ReadFromText('path\My_sample_input_file.txt');
lines | beam.io.WriteToText('path\output2.txt')
您不应将 -m
标志用于 运行 脚本。参见 What is the purpose of the -m switch?
到运行一个python脚本:
python myfile.py
导入并运行一个模块:
python -m myfile
这也有效,因为当前工作目录位于 python 个模块的搜索路径中。