You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/machine-learning/install/custom-runtime-python.md
+66-63Lines changed: 66 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,37 +17,38 @@ This article describes how to install a custom runtime for running Python script
17
17
18
18
+ An installation of SQL Server with extensibility framework.
19
19
20
-
+ An installation of SQL Machine Learning Services for SQL Server 2019. The language extension can be used with [SQL Server Machine Learning Services](../sql-server-machine-learning-services.md) after completing some additional configuration steps.
20
+
+ An installation of Machine Learning Services with SQL Server 2019. The language extension can be used with [SQL Server Machine Learning Services](../sql-server-machine-learning-services.md) after completing some additional configuration steps.
> This article describes how to install a custom runtime for Python on Windows. To install on Linux, see the [Install a Python custom runtime for SQL Server on Linux](custom-runtime-python.md?view=sql-server-linux-ver15&preserve-view=true)
25
+
> This article describes how to install a custom runtime for Python on Windows. To install on Linux, see [Install a Python custom runtime for SQL Server on Linux](custom-runtime-python.md?view=sql-server-linux-ver15&preserve-view=true).
25
26
26
27
## Pre-install checklist
27
28
28
-
+[SQL Server 2019 for Windows CU3 or later.](../../database-engine/install-windows/install-sql-server.md)
29
+
Before installing a Python custom runtime, install the following:
30
+
31
+
+[SQL Server 2019 for Windows CU3 or later](../../database-engine/install-windows/install-sql-server.md).
29
32
30
33
> [!NOTE]
31
34
> Python custom runtime requires Cumulative Update (CU) 3 or later for SQL Server 2019.
32
35
33
-
+[SQL Server Language Extensions on Windows with the extensibility framework.](../../language-extensions/install/install-sql-server-language-extensions-on-windows.md)
36
+
+[SQL Server Language Extensions on Windows with the extensibility framework](../../language-extensions/install/install-sql-server-language-extensions-on-windows.md).
> For Machine Learning Services using SQL Server 2019, the extensibility framework for language extensions is already installed and you can skip this step.
43
+
> If you have Machine Learning Services installed on SQL Server 2019, the extensibility framework is already installed and you can skip this step.
41
44
42
45
Language Extensions use the extensibility framework for executing external code. Code execution is isolated from the core engine processes, but fully integrated with SQL Server query execution.
43
46
44
-
Complete the setup for SQL Server 2019.
45
-
46
-
1. Start the setup wizard for SQL Server 2019.
47
+
1. Start the setup wizard for SQL Server 2019.
47
48
48
49
1. On the **Installation** tab, select **New SQL Server stand-alone installation or add features to an existing installation**.
49
50
50
-

51
+

51
52
52
53
1. On the **Feature Selection** page, select these options:
53
54
@@ -57,7 +58,7 @@ Complete the setup for SQL Server 2019.
57
58
58
59
-**Machine Learning Services and Language Extensions**
59
60
60
-
Select **Machine Learning Services and Language Extensions** There's no need to select Python.
61
+
Select **Machine Learning Services and Language Extensions**. There's no need to select Python.
61
62
62
63

63
64
@@ -71,7 +72,7 @@ Complete the setup for SQL Server 2019.
71
72
72
73
## Install Python 3.7
73
74
74
-
[Install Python 3.7 and add it to the PATH.](https://www.python.org/downloads/release/python-379/)
75
+
Install [Python 3.7](https://www.python.org/downloads/release/python-379/) and add it to the PATH.
75
76
76
77
**update image - note**
>The above command grants permissions to the computer **SID S-1-15-2-1**, which is equivalent to ALL APPLICATION PACKAGES on an English version of Windows. Alternatively, you can use `icacls "%R_HOME%" /grant "ALL APPLICATION PACKAGES":(OI)(CI)RX /T` on an English version of Windows.
118
+
>The preceding command grants permissions to the computer **SID S-1-15-2-1**, which is equivalent to ALL APPLICATION PACKAGES on an English version of Windows. Alternatively, you can use `icacls "%R_HOME%" /grant "ALL APPLICATION PACKAGES":(OI)(CI)RX /T` on an English version of Windows.
121
119
122
120
## Restart SQL Server Launchpad service
123
121
124
-
Find the name of the SQL Server Launchpad Service. It is of the form MSSQLLAUNCHPAD$INSTANCENAME where INSTANCENAME is the instance name of your SQL Server. From an *elevated* command prompt, run the following commands (in this example, INSTANCENAME is the default instance `MSSQLSERVER`).
122
+
From an *elevated* command prompt, run the following commands. Replace "MSSQLSERVER" with the name of your SQL Server instance.
125
123
126
124
```CMD
127
125
net stop MSSQLLAUNCHPAD$MSSQLSERVER
@@ -132,15 +130,15 @@ Alternatively, right-click the SQL Server Launchpad service in the **Services**
132
130
133
131
## Download Python language extension
134
132
135
-
Download the zip file containing the Python language extension (python-lang-extension.zip) from [here.](**GitHub link goes here**)
133
+
Download the zip file containing the Python language extension (python-lang-extension.zip) from [here](**GitHub link goes here**).
136
134
137
135
## Register external language
138
136
139
-
For each database you want to use this Python language extension, you need to register it with [CREATE EXTERNAL LANGUAGE](../../t-sql/statements/create-external-language-transact-sql.md).
140
-
Use [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio) to connect to SQL Server and run the following T-SQL. Modify the path in this statement to reflect the location of the downloaded language extension zip file (python-lang-extension.zip) from above.
137
+
Register this Python language extensionwith [CREATE EXTERNAL LANGUAGE](../../t-sql/statements/create-external-language-transact-sql.md) for each database you want to use it in.
138
+
Use [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio) to connect to SQL Server and run the following T-SQL command. Modify the path in this statement to reflect the location of the downloaded language extension zip file (python-lang-extension.zip).
141
139
142
140
> [!NOTE]
143
-
>Python is a reserved word. Use a different name for the external language, e.g. myPython.
141
+
>Python is a reserved word. Use a different name for the external language, for example, "myPython".
You can install SQL Server on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu. For more information, see [the Supported platforms section in the Installation guidance for SQL Server on Linux](../../linux/sql-server-linux-setup.md).
155
154
156
155
> [!NOTE]
157
156
> This article describes how to install a custom runtime for Python on Linux. To install on Windows, see the [Install a Python custom runtime for SQL Server on Windows](custom-runtime-python.md?view=sql-server-ver15&preserve-view=true)
158
157
159
158
## Pre-install checklist
160
159
161
-
+[SQL Server 2019 for Linux (Cumulative Update 3 onwards).](../../linux/sql-server-linux-setup.md)
160
+
Before installing a Python custom runtime, install the following:
161
+
162
+
+[SQL Server 2019 for Linux (Cumulative Update 3 or later)](../../linux/sql-server-linux-setup.md).
162
163
When you install SQL Server on Linux, you must configure a Microsoft repository. For more information, see [configuring repositories](../../linux/sql-server-linux-change-repo.md)
163
164
164
165
> [!NOTE]
165
166
> Python custom runtime requires Cumulative Update (CU) 3 or later for SQL Server 2019.
166
167
167
-
+[SQL Server Language Extensions on Linux with the extensibility framework.](../../linux/sql-server-linux-setup-language-extensions.md)
168
+
+[SQL Server Language Extensions on Linux with the extensibility framework](../../linux/sql-server-linux-setup-language-extensions.md).
> For Machine Learning Services using SQL Server 2019, the **mssql-server-extensibility** package for language extensions is already installed and you can skip this step.
175
+
> If you have Machine Learning Services installed on SQL Server 2019, the **mssql-server-extensibility** package for language extensions is already installed and you can skip this step.
175
176
176
177
Language Extensions use the extensibility framework for executing external code. Code execution is isolated from the core engine processes, but fully integrated with SQL Server query execution.
177
178
179
+
Use the following commands to install Language Extensions, depending on your version of Linux.
180
+
178
181
### Ubuntu
179
182
> [!Tip]
180
183
> If possible, `update` to refresh packages on the system prior to installation. Ubuntu might not have the https apt transport option. To install it, use `apt-get install apt-transport-https`.
> If you have installed Python in the default location of **/usr/lib/python3.7**, you can skip to [the next section](#download-python-linux).
219
222
220
-
If you built your own version of Python 3.7, follow the following steps so that SQL Server can find and load your custom installation.
223
+
If you built your own version of Python 3.7, use the following commands so that SQL Server can find and load your custom installation.
221
224
222
-
####Update the environment variables
225
+
### Update the environment variables
223
226
224
227
1. Add the PYTHONHOME environment variable to the mssql-launchpadd service config.
225
228
226
229
+ Edit **mssql-launchpadd** service.
227
230
228
-
```bash
229
-
sudo systemctl edit mssql-launchpadd
230
-
```
231
+
```bash
232
+
sudo systemctl edit mssql-launchpadd
233
+
```
231
234
232
235
+ Insert the following text in the **/etc/systemd/system/mssql-launchpadd.service.d/override.conf** file that opens. Set value of PYTHONHOME to the custom Python installation path.
2. Make sure **libpython3.7m.so.1.0** can be loaded.
242
245
243
246
+ Create a custom-python.conf file in**/etc/ld.so.conf.d**.
244
247
245
-
```bash
246
-
sudo vi /etc/ld.so.conf.d/custom-python.conf
247
-
```
248
+
```bash
249
+
sudo vi /etc/ld.so.conf.d/custom-python.conf
250
+
```
248
251
249
-
+ In the file that opens, add path to **libpython3.7m.so.1.0** from the custom Python installation.
252
+
+ In the file that opens, add the path to **libpython3.7m.so.1.0** from the custom Python installation.
250
253
251
-
```vi
252
-
/path/to/installation/of/python3.7/lib
253
-
```
254
+
```vi
255
+
/path/to/installation/of/python3.7/lib
256
+
```
254
257
255
258
+ Save and close the new file.
256
259
257
260
+ Run `ldconfig` and verify **libpython3.7m.so.1.0** can be loaded by running the following commands and checking that all the dependent libraries can be found.
## <a name="download-python-linux"></a> Download Python language extension
281
284
282
-
Download the zip file containing the Python language extension (**python-lang-extension.zip**) from [here.](**GitHub link goes here**)
285
+
Download the zip file containing the Python language extension (**python-lang-extension.zip**) from [here](**GitHub link goes here**).
283
286
284
287
## Register external language
285
288
286
-
For each database you want to use this python language extension, you need to register it with [CREATE EXTERNAL LANGUAGE](../../t-sql/statements/create-external-language-transact-sql.md).
287
-
Use [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio) to connect to SQL Server and run the following T-SQL.
288
-
289
-
Modify the path in this statement to reflect the location of the downloaded language extension zip file (python-lang-extension.zip) from above.
289
+
Register this Python language extension with [CREATE EXTERNAL LANGUAGE](../../t-sql/statements/create-external-language-transact-sql.md) for each database you want to use it in.
290
+
Use [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio) to connect to SQL Server and run the following T-SQL command.
291
+
Modify the path in this statement to reflect the location of the downloaded language extension zip file (python-lang-extension.zip).
290
292
291
293
> [!NOTE]
292
-
>Python is a reserved word. Use a different name for the external language e.g. myPython.
294
+
>Python is a reserved word. Use a different name for the external language, for example, "myPython".
293
295
294
296
```sql
295
297
CREATE EXTERNAL LANGUAGE myPython
@@ -302,17 +304,18 @@ GO
302
304
303
305
## Enable external script execution in SQL Server
304
306
305
-
An external script in Python can be executed via the stored procedure [sp_execute_external script](../../relational-databases/system-stored-procedures/sp-execute-external-script-transact-sql.md) run against SQL Server. Execute the following script using [Azure Data Studio.](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio)
307
+
An external script in Python can be executed via the stored procedure [sp_execute_external script](../../relational-databases/system-stored-procedures/sp-execute-external-script-transact-sql.md) run against SQL Server.
308
+
309
+
To enable external scripts, execute the following SQL commands using [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio), connected to SQL Server.
306
310
307
311
```sql
308
312
sp_configure 'external scripts enabled', 1;
309
313
RECONFIGURE WITH OVERRIDE;
310
314
```
311
315
312
316
## Verify language extension installation
313
-
Use SQL Azure Data Studio to connect to SQL Server.
314
317
315
-
This script tests the functionality of the installed language extension.
318
+
This SQL script tests the functionality of the installed language extension.
0 commit comments