Python Packages in SQL Server – Get Started with SQL Server Machine Learning Services – Part 5


When installing Machine Learning Services in SQL Server by default few Python Packages are installed. In this article, we will have a look on how to get those installed python package information.

Python Packages

When we choose Python as Machine Learning Service during installation, the following packages are installed in SQL Server,

  • revoscalepy – This Microsoft Python package is used for remote compute contexts, streaming, parallel execution of rx functions for data import and transformation, modeling, visualization, and analysis.
  • microsoftml – This is another Microsoft Python package which adds machine learning algorithms in Python.
  • Anaconda 4.2 – Anaconda is an opensource Python package

Get all installed Python Packages

The below T-SQL Statements lists all installed Python Packages.

EXECUTE sp_execute_external_script
  @language = N'Python',
  @script = N'
import pkg_resources
import pandas
OutputDataSet = pandas.DataFrame(sorted([(i.key, i.version) for i in pkg_resources.working_set]))'
WITH result sets((Package NVARCHAR(128), Version NVARCHAR(128)));

From the above statement, pkg_resources contains the information about the Python packages and we are looping it get details of each packages. i.key in the for loop holds the information about the Package name and i.version holds the information about the version. And the T-SQL Statement results as,

Fig. 1 Installed Python Packages

At this time of writing this article, the T-SQL Statement results 164 rows of Package information. In this T-SQL Statement we are not able to see the version of these packages. To get version details, we have to use import sys.

Version of Python

To get the Python package version, we have to import the sys. The below T-SQL statement shows how to get the version of Python,

EXECUTE sp_execute_external_script
  @language = N'Python',
  @script = N'
import sys

The sys.version results the Python version.

Fig.2 Python Version


In this article, we have discussed about the default Python packages installed while setting up the Machine Learning Services in SQL Server installing. We can also install more packages, which we will discuss in our upcoming articles. I hope you all found this article much useful. Please share your feedback in the comment section.

Other Articles in this Series

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with

Up ↑

%d bloggers like this: