Python - ImportError: No module Cloud Dataproc
Python - ImportError: No module Cloud Dataproc
我在 Google Cloud Dataproc 的 python 项目结构方面遇到问题。我有许多文件都在同一个文件夹中,并且通过 import
相互调用。整体程序 运行 在当地没问题。
但是,当我将其放入 Google Cloud Dataproc 时,import
出现问题。我已经尝试了此 答案中提供的答案,但没有效果。
错误如下:
from model import PolicyEmergence
ImportError: No module named model
我尝试使用 sys.path.insert(0, 'gs://bucket-name/')
强制路径,但无济于事。我不确定这是否是由于我每次 运行 作业时都在更改路径。
欢迎任何帮助,谢谢。
你可能想要:
from model import PolicyEmergence
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 *
要从该文件 (model.py) 导入您的 class (PolicyEmergence),您应该删除 [.py]:
from model import PolicyEmergence
图斯
我在 Google Cloud Dataproc 的 python 项目结构方面遇到问题。我有许多文件都在同一个文件夹中,并且通过 import
相互调用。整体程序 运行 在当地没问题。
但是,当我将其放入 Google Cloud Dataproc 时,import
出现问题。我已经尝试了此
错误如下:
from model import PolicyEmergence
ImportError: No module named model
我尝试使用 sys.path.insert(0, 'gs://bucket-name/')
强制路径,但无济于事。我不确定这是否是由于我每次 运行 作业时都在更改路径。
欢迎任何帮助,谢谢。
你可能想要:
from model import PolicyEmergence
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 *
要从该文件 (model.py) 导入您的 class (PolicyEmergence),您应该删除 [.py]:
from model import PolicyEmergence
图斯