Home:ALL Converter>Azure DataBrick PYTHONPATH pointing at imported wheel?

Azure DataBrick PYTHONPATH pointing at imported wheel?

Ask Time:2021-03-28T14:34:26         Author:user3761555

Json Formatter

I successfully created a python wheel of my python project following simple steps from here: https://python101.pythonlibrary.org/chapter39_wheels.html

Then from my DataBrick Notebook, installed my project dependencies (I uploaded separately my project's requirements.txt to my blob storage):

%pip install -r /dbfs/mnt/testdb-blob-container1/requirements.txt

I then uploaded python wheel of my project via Azure DataBrick interface: https://learn.microsoft.com/en-us/azure/databricks/libraries/workspace-libraries

From my DataBrick Notebook, i successfully reference:

import myproject
import myproject.src
from myproject.src.core import constants as constants   <-- This is fine.

But this blew up because my datetimeutil needs "constants". From local, we have PYTHONPATH. In DataBrick, we dont have this, so below attempt to import datetimeutil below up:

  from myproject.src.helpers import datetimeutil as datetimeutil

How do we set PYTHONPATH in DataBrick environment?

One thing i tried is... my wheel file is here:

dbfs:/FileStore/jars/23011937_5e16_4be0_b82a_88e83aaecadf/myproject-1.0-py3-none-any.whl

From my notebook:

import sys
sys.path.append("dbfs:/FileStore/jars/23011937_5e16_4be0_b82a_88e83aaecadf/")

This did not work.

Thanks

Author:user3761555,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/66838969/azure-databrick-pythonpath-pointing-at-imported-wheel
yy