Currently, Snowpark API supports only Python 3.8. We can create a virtual environment with Python 3.8 using conda and installing the numpy and pandas packages by typing:
conda create --name py38_env --override-channels -c https://repo.anaconda.com/pkgs/snowflake python=3.8 numpy pandas
Then, we should activate the py38_env
and install the following packages:
conda install snowflake-snowpark-python conda install snowflake-snowpark-python pandas pip install notebook
Note that there is a known issue with running Snowpark Python on Apple M1 chips due to memory handling in pyOpenSSL. The error message displayed is, “Cannot allocate write+execute memory for ffi.callback()”.
As a workaround, set up a virtual environment that uses x86 Python using these commands:
CONDA_SUBDIR=osx-64 conda create -n snowpark python=3.8 numpy pandas --override-channels -c https://repo.anaconda.com/pkgs/snowflake conda activate snowpark conda config --env --set subdir osx-64
Access Snowpark with OKTA via Jupyter Notebook
Within the “py38_env” virtual environment, we can type to start the Jupyter Notebook
jupyter notebook
Once we open the Jupyter Notebook we can type:
from snowflake.snowpark import Session connection_parameters = { "user":'<your_email>@<domain>.<com>', "authenticator" : 'https://<company_domain>.okta.com', "password":'<your_password>', "account":'<your account>', "warehouse":'COMPUTE_WH', "database":'GPIPIS_DB', "schema":'PUBLIC', "role" : 'SYSADMIN' } new_session = Session.builder.configs(connection_parameters).create() # we get: <snowflake.snowpark.session.Session at 0x25f127ff530> new_session.sql("SELECT count(*) FROM test_table").collect() #we get [Row(COUNT(*)=229)] #close the session new_session.close()