surya
surya

Reputation: 3

Why does it say attribute error while running apache beam on local machine?

I am trying to run the apache beam program using Python SDK on my local machine. I created and activated the python virtual environment and also installed apache beam using pip.

However, when I trigger the code using the below command, it gives the attribute error and says:

module filename.py has no attribute __path__

Below is the command I ran (by going to the venv folder):

python -m filename.py

Please help me out on this.. I am trying to learn 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')

Upvotes: 0

Views: 527

Answers (1)

oLas
oLas

Reputation: 1241

You shouldn't use the -m flag to run a script. See What is the purpose of the -m switch?

To run a python script:

python myfile.py

To import and run a module:

python -m myfile

This will also work because the current working directory is in the search path for python modules.

Upvotes: 1

Related Questions