Snowflake-Labs / sfguide-intro-to-machine-learning-with-snowflake-ml-for-python

Apache License 2.0
54 stars 111 forks source link

Import Error in 2_snowpark_ml_feature_transformations.ipynb #5

Closed brownie1 closed 1 year ago

brownie1 commented 1 year ago

When importing the libraries for doing the transformations running the first cell gives the following error:

ImportError Traceback (most recent call last) Cell In[8], line 14 11 from snowflake.snowpark.types import DecimalType 13 # Snowpark ML ---> 14 import snowflake.ml.modeling.preprocessing as snowml 15 from snowflake.ml.modeling.pipeline import Pipeline 16 from snowflake.ml.modeling.metrics.correlation import correlation

File ~/anaconda3/envs/snowpark/lib/python3.10/site-packages/snowflake/ml/modeling/preprocessing/init.py:7 5 pkg_dir = os.path.dirname(os.path.abspath(file)) 6 pkg_name = name ----> 7 exportable_classes = init_utils.fetch_classes_from_modules_in_pkg_dir(pkg_dir=pkg_dir, pkg_name=pkg_name) 8 for k, v in exportable_classes.items(): 9 globals()[k] = v

File ~/anaconda3/envs/snowpark/lib/python3.10/site-packages/snowflake/ml/_internal/init_utils.py:26, in fetch_classes_from_modules_in_pkg_dir(pkg_dir, pkg_name) 24 # import the module and iterate through its attributes 25 try: ---> 26 module = importlib.import_module(f"{pkg_name}.{module_info.name}") 27 for attribute_name in dir(module): 28 attribute = getattr(module, attribute_name)

File ~/anaconda3/envs/snowpark/lib/python3.10/importlib/init.py:126, in import_module(name, package) 124 break 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level)

File ~/anaconda3/envs/snowpark/lib/python3.10/site-packages/snowflake/ml/modeling/preprocessing/polynomial_features.py:32 30 from snowflake.snowpark import DataFrame, Session 31 from snowflake.snowpark.functions import pandas_udf, sproc ---> 32 from snowflake.snowpark.types import PandasSeries 33 from snowflake.snowpark._internal.type_utils import convert_sp_to_sf_type 34 from snowflake.snowpark._internal.utils import ( 35 TempObjectType, 36 random_name_for_temp_object, 37 )

ImportError: cannot import name 'PandasSeries' from 'snowflake.snowpark.types'

ShenShu2016 commented 1 year ago

I have no problem with it. It required python 3.9 , yours is 3.10. Using the same dependencies from conda_env.yml It may help you to fix the problem

brownie1 commented 1 year ago

I re-created the environment with 3.9 and it worked.