Ekinlikler
31 Mar 23 - 2 Nis 23
En büyük SQL, Fabric ve Power BI öğrenme etkinliği. 31 Mart – 2 Nisan. 400 ABD doları tasarruf etmek için FABINSIDER kodunu kullanın.
Bugün kaydolunBu tarayıcı artık desteklenmiyor.
En son özelliklerden, güvenlik güncelleştirmelerinden ve teknik destekten faydalanmak için Microsoft Edge’e yükseltin.
Applies to:
SQL Server 2017 (14.x) and later
Azure SQL Managed Instance
This article describes how to get information about installed Python packages, including versions and installation locations, on Machine Learning Services on SQL Server and on Big Data Clusters. Example Python scripts show you how to list package information such as installation path and version.
This article describes how to get information about installed Python packages, including versions and installation locations, on SQL Server Machine Learning Services. Example Python scripts show you how to list package information such as installation path and version.
This article describes how to get information about installed Python packages, including versions and installation locations, on Azure SQL Managed Instance Machine Learning Services. Example Python scripts show you how to list package information such as installation path and version.
When you install machine learning with SQL Server, a single package library is created at the instance level for each language that you install. The instance library is a secured folder registered with SQL Server.
All script or code that runs in-database on SQL Server must load functions from the instance library. SQL Server can't access packages installed to other libraries. This applies to remote clients as well: any Python code running in the server compute context can only use packages installed in the instance library. To protect server assets, the default instance library can be modified only by a computer administrator.
The default path of the binaries for Python is:
C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES
This assumes the default SQL instance, MSSQLSERVER. If SQL Server is installed as a user-defined named instance, the given name is used instead.
The default path of the binaries for Python is:
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES
This assumes the default SQL instance, MSSQLSERVER. If SQL Server is installed as a user-defined named instance, the given name is used instead.
Enable external scripts by running the following SQL commands:
sp_configure 'external scripts enabled', 1;
RECONFIGURE WITH override;
Önemli
On Azure SQL Managed Instance, running the sp_configure and RECONFIGURE commands triggers a SQL server restart for the RG settings to take effect. This can cause a few seconds of unavailability.
Run the following SQL statement if you want to verify the default library for the current instance. This example returns the list of folders included in the Python sys.path
variable. The list includes the current directory and the standard library path.
EXECUTE sp_execute_external_script
@language =N'Python',
@script=N'import sys; print("\n".join(sys.path))'
For more information about the variable sys.path
and how it's used to set the interpreter's search path for modules, see The Module Search Path.
Not
Don't try to install Python packages directly in the SQL package library using pip or similar methods. Instead, use sqlmlutils to install packages in a SQL instance. For more information, see Install Python packages with sqlmlutils.
The following Microsoft Python packages are installed with SQL Server Machine Learning Services when you select the Python feature during setup.
Packages | Version | Description |
---|---|---|
revoscalepy | 9.4.7 | Used for remote compute contexts, streaming, parallel execution of rx functions for data import and transformation, modeling, visualization, and analysis. |
microsoftml | 9.4.7 | Adds machine learning algorithms in Python. |
For information on which version of Python is included, see Python and R versions.
By default, Python packages are refreshed through service packs and cumulative updates. Additional packages and full version upgrades of core Python components are possible only through product upgrades.
When you select the Python language option during setup, Anaconda 4.2 distribution (over Python 3.5) is installed. In addition to Python code libraries, the standard installation includes sample data, unit tests, and sample scripts.
Önemli
You should never manually overwrite the version of Python installed by SQL Server Setup with newer versions on the web. Microsoft Python packages are based on specific versions of Anaconda. Modifying your installation could destabilize it.
The following example script displays a list of all Python packages installed in the SQL Server instance.
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)));
If you've installed a Python package and want to make sure that it's available to a particular SQL Server instance, you can execute a stored procedure to look for the package and return messages.
For example, the following code looks for the scikit-learn
package.
If the package is found, the code prints the package version.
EXECUTE sp_execute_external_script
@language = N'Python',
@script = N'
import pkg_resources
pkg_name = "scikit-learn"
try:
version = pkg_resources.get_distribution(pkg_name).version
print("Package " + pkg_name + " is version " + version)
except:
print("Package " + pkg_name + " not found")
'
Result:
STDOUT message(s) from external script: Package scikit-learn is version 0.20.2
The following example code returns the version of Python installed in the instance of SQL Server.
EXECUTE sp_execute_external_script
@language = N'Python',
@script = N'
import sys
print(sys.version)
'
Ekinlikler
31 Mar 23 - 2 Nis 23
En büyük SQL, Fabric ve Power BI öğrenme etkinliği. 31 Mart – 2 Nisan. 400 ABD doları tasarruf etmek için FABINSIDER kodunu kullanın.
Bugün kaydolunEğitim
Öğrenme yolu
SQL Server 2022 özelliklerini keşfetme - Training
SQL Server 2022 özelliklerini keşfetme
Sertifikasyon
Microsoft Sertifikalı: Azure Veri Bilimcisi İş Ortağı - Certifications
Python, Azure Machine Learning ve MLflow ile veri alımını ve hazırlığını, model eğitimini ve dağıtımlarını ve makine öğrenmesi çözümü izlemeyi yönetin.
Belgeler
Install Python packages with sqlmlutils - SQL Server Machine Learning Services
Learn how to use Python pip to install new Python packages on an instance of SQL Server Machine Learning Services.
Python language extension - SQL Server Machine Learning Services
Learn about the Python extension for running external Python scripts with SQL Server Machine Learning Services.
Install Python custom runtime - SQL Server Machine Learning Services
Learn how to install a Python custom runtime for SQL Server using Language Extensions. The Python custom runtime can run machine learning scripts.