Reputation: 3
I am having an issue with Google Cloud Dataproc with the structuring of my python project. I have a number of files which are all in the same folders and which call one another through import
. The overall program runs fine locally.
However, when I place it in Google Cloud Dataproc, I have an issue with import
. I have tried the answers presented in this Python can't find my module answer but to no effect.
The error is the following:
from model import PolicyEmergence
ImportError: No module named model
I tried to force the path using sys.path.insert(0, 'gs://bucket-name/')
but to no avail. I am not sure if this is due to the changing path every time I run the job.
Any help would be welcome, thanks.
Upvotes: 0
Views: 1235
Reputation: 16
The
from [...] import [...]
requires as first argument a [directory.]file where your classes are and secondly a specific name of your class or * you want to import from there.for example:
# The .py must be omitted!
from mymodule import *
To import your class (PolicyEmergence) from that file (model.py) you should delete the [.py]:
from model import PolicyEmergence
Tusr
Upvotes: 0