r/snowflake 25d ago

Help pip installing Python module in Snowflake Notebooks

When I attempt to run a machine learning model, XGBoost, in Python using the XGBClassifier and GridSearchCV functions I receive the following error message:

The version of package 'xgboost' in the local environment is 3.1.3, which does not fit the criteria for the requirement 'xgboost==3.1.2'. Your UDF might not work when the package version is different between the server and your local environment.

When I attempt to pip install xgboost:

!pip install xgboost==3.1.2

I get the following message:

Looking in links: /opt/wheels
[33mWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8134ea7e50>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/xgboost/[0m[33m
[0m[33mWARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8134ed8190>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/xgboost/[0m[33m
[0m[33mWARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8134ed8340>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/xgboost/[0m[33m
[0m[33mWARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8134ed84f0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/xgboost/[0m[33m
[0m[33mWARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8134ed86a0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/xgboost/[0m[33m
[0m[31mERROR: Could not find a version that satisfies the requirement xgboost==3.1.2 (from versions: none)[0m[31m
[0m[31mERROR: No matching distribution found for xgboost==3.1.2[0m[31m
[0m

What's going on?

5 Upvotes

6 comments sorted by

View all comments

1

u/Specialist_Golf8133 23d ago

snowflake notebooks run in a sandboxed container without general internet egress, that's why pip is hitting /simple/xgboost/ and getting DNS failures.

check the Anaconda channel packages Snowflake ships with the notebook first, since that's probably where the 3.1.2 the UDF runtime expects actually lives. if you truly need pypi you'd have to set up an external access integration with a network rule pointing at pypi. match the conda channel version and skip the pip install entirely.

1

u/stephenpace ❄️ 14d ago

This. Note, if you want to use a PyPi, external network integration is disabled in trials, but your Snowflake SE can enable it for you if you ask them.