【发布时间】:2021-07-02 04:51:45
【问题描述】:
我创建了一个 python 轮文件,其中包含两个具有一些自定义模块的 python 文件(file1.py 和 file2.py)。 file2.py 依赖于 file1.py。
创建wheel文件后我的本地目录是这样的:
myfunc_wheel
├── build
|--myfunc.eg-info
└── myfuncpkg
|_ __init__.py
└── file1.py
|__ file2.py
|__ dist
|__myfunc-0.01-pu3-none-any.whl
|__ setup.py
file1.py:
def hello_world():
print("hello world")
file2.py
import file1
#some functions
setup.py:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="myfunc",
version="0.0.1",
author="xxx",
author_email="x",
description="xxxx",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.7',
)
当我在本地同时运行 file1 和 file2 时,它没有抛出错误。
但是当我在 Databricks 集群上安装了 wheel 文件并尝试在 Databricks 笔记本中导入模块后,它抛出了 file2 找不到 file1 的错误。
from myfuncpkf import file1
from myfuncpkg import file2
ModuleNotFoundError: No module named 'file1'
我也尝试过将整个路径放到 file1 中,但也没有用。
我应该如何调整我的文件以使依赖项在 Databricks 上工作?
【问题讨论】:
标签: python jupyter-notebook databricks python-wheel