planetary-computer-sdk-for-python icon indicating copy to clipboard operation
planetary-computer-sdk-for-python copied to clipboard

ImportError: cannot import name dataclass_transform

Open cheukhin1024 opened this issue 3 years ago • 6 comments
trafficstars

Cannot import name dataclass_transform by PyPl installing planetary-computer

擷取

cheukhin1024 avatar Oct 05 '22 05:10 cheukhin1024

What version of Python do you have, and how did you install planetary-computer? I can't reproduce this in a new virtual environment

❯ python3 -m pip install planetary-computer
❯ python3 -c "import planetary_computer"

Are you able to post the full traceback? dataclass_transform isn't a (direct) dependency of planetary computer, but maybe one of the dependencies is pulling it in.

TomAugspurger avatar Oct 05 '22 11:10 TomAugspurger

What version of Python do you have, and how did you install planetary-computer? I can't reproduce this in a new virtual environment

❯ python3 -m pip install planetary-computer
❯ python3 -c "import planetary_computer"

Are you able to post the full traceback? dataclass_transform isn't a (direct) dependency of planetary computer, but maybe one of the dependencies is pulling it in.

My Azure Databricks is using 11.2 ML Databricks Runtime. I assume the Python version is 3.7/3.8.

I installed the PyPl planetary_computer package.

Here is the full traceback: 擷取

I copied the code form Microsoft Planetary Computer Example Notebook

cheukhin1024 avatar Oct 12 '22 04:10 cheukhin1024

Can you create a clean virtual environment and try there? I'm wondering if some existing package is incompatible with our dependencies (possibly pydantic is pulling in this dependency, but that should have been fixed in https://github.com/pydantic/pydantic/issues/4423).

TomAugspurger avatar Oct 12 '22 11:10 TomAugspurger

The code works in Planetary Computer Hub, but it doesn't work in Azure Databricks.

Here are the Databricks Runtime 11.2 ML Version Libaries

cheukhin1024 avatar Oct 12 '22 16:10 cheukhin1024

I haven't used Databricks before, so it'll be a while before I can look into this. But I suspect it's nothing particular to this package and would happen any time you try to import pydantic / its dependencies.

I'm guessing it's "just" a matter of getting the package configuration correct.

TomAugspurger avatar Oct 12 '22 16:10 TomAugspurger

There is Pydantic 1.9.2 in Databricks Runtime 11.2 ML Version while there is no Pydantic in Databricks Runtime 11.2 Version, but these 2 versions also have the same error (ImportError: cannot import name dataclass_transform) after my testing.

cheukhin1024 avatar Oct 12 '22 17:10 cheukhin1024

FYI, I've heard that things do work with the Runtime 11.3 version, as long as you restart things after installing planetary-computer.

TomAugspurger avatar Mar 19 '23 15:03 TomAugspurger