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
+10-18Lines changed: 10 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,6 @@ Install the [pandas](https://pandas.pydata.org/) package for Python from an *ele
84
84
python.exe -m pip install pandas
85
85
```
86
86
87
-
88
87
## Update the system environment variables
89
88
90
89
Add or modify PYTHONHOME as a system environment variable.
@@ -100,12 +99,11 @@ To modify select **Edit** to change PYTHONHOME. Modify PYTHONHOME to point to th
100
99
101
100

102
101
103
-
104
102
## Grant access to the custom Python installation folder
105
103
106
-
Run the following **icacls** commands from a new *elevated* command prompt to grant READ & EXECUTE access to PYTHONHOME to **SQL Server Launchpad Service** and SID **S-1-15-2-1** (**ALL_APPLICATION_PACKAGES**). The launchpad service username is of the form *NT Service\MSSQLLAUNCHPAD$INSTANCENAME* where INSTANCENAME is the instance name of your SQL Server. The commands will recursively grant access to all files and folders under the given directory path.
104
+
Run the following **icacls** commands from a new *elevated* command prompt to grant READ & EXECUTE access to PYTHONHOME to **SQL Server Launchpad Service** and SID **S-1-15-2-1** (**ALL_APPLICATION_PACKAGES**). The launchpad service username is of the form `NT Service\MSSQLLAUNCHPAD$INSTANCENAME* where INSTANCENAME` is the instance name of your SQL Server. The commands will recursively grant access to all files and folders under the given directory path.
107
105
108
-
Append the instance name to MSSQLLAUNCHPAD (`MSSQLLAUNCHPAD$INSTANCENAME`). In this example, INSTANCENAME is the default instance `MSSQLSERVER`.
106
+
Append the instance name to `MSSQLLAUNCHPAD` (`MSSQLLAUNCHPAD$INSTANCENAME`). In this example, INSTANCENAME is the default instance `MSSQLSERVER`.
109
107
110
108
1. Give permissions to **SQL Server Launchpad Service user name**
111
109
@@ -176,7 +174,7 @@ When you install SQL Server on Linux, you must configure a Microsoft repository.
176
174
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
175
178
176
### Ubuntu
179
-
> [!Tip]
177
+
> [!TIP]
180
178
> 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).
216
+
> 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
217
220
218
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.
221
219
222
220
#### Update the environment variables
223
221
224
-
1. Add the PYTHONHOME environment variable to the mssql-launchpadd service config.
225
-
226
-
+ Edit **mssql-launchpadd** service.
222
+
1. Edit the mssql-launchpadd service to add the PYTHONHOME environment variable to the file `/etc/systemd/system/mssql-launchpadd.service.d/override.conf`
227
223
228
224
```bash
229
225
sudo systemctl edit mssql-launchpadd
230
226
```
231
227
232
-
+ 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.
228
+
+ 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.
233
229
234
230
```vi
235
231
[Service]
@@ -238,23 +234,23 @@ If you built your own version of Python 3.7, follow the following steps so that
238
234
239
235
+ Save and close.
240
236
241
-
2. Make sure **libpython3.7m.so.1.0** can be loaded.
237
+
2. Make sure `libpython3.7m.so.1.0` can be loaded.
242
238
243
-
+ Create a custom-python.conf file in**/etc/ld.so.conf.d**.
239
+
+ Create a custom-python.conf file in`/etc/ld.so.conf.d`.
244
240
245
241
```bash
246
242
sudo vi /etc/ld.so.conf.d/custom-python.conf
247
243
```
248
244
249
-
+ In the file that opens, add path to **libpython3.7m.so.1.0** from the custom Python installation.
245
+
+ In the file that opens, add path to `libpython3.7m.so.1.0` from the custom Python installation.
250
246
251
247
```vi
252
248
/path/to/installation/of/python3.7/lib
253
249
```
254
250
255
251
+ Save and close the new file.
256
252
257
-
+ 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.
253
+
+ 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.
258
254
259
255
```bash
260
256
sudo ldconfig
@@ -274,9 +270,6 @@ sudo /opt/mssql/bin/mssql-conf set extensibility.datadirectories /path/to/instal
274
270
```bash
275
271
sudo systemctl restart mssql-launchpadd
276
272
```
277
-
278
-
279
-
280
273
## <a name="download-python-linux"></a> Download Python language extension
281
274
282
275
Download the zip file containing the Python language extension (**python-lang-extension.zip**) from [here.](**GitHub link goes here**)
@@ -299,7 +292,6 @@ GO
299
292
300
293
::: moniker-end
301
294
302
-
303
295
## Enable external script execution in SQL Server
304
296
305
297
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)
Copy file name to clipboardExpand all lines: docs/machine-learning/install/custom-runtime-r.md
+40-42Lines changed: 40 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,6 @@ This article describes how to install a custom runtime for running R scripts wit
24
24
> [!NOTE]
25
25
> This article describes how to install a custom runtime for R on Windows. To install on Linux, see the [Install an R custom runtime for SQL Server on Linux](custom-runtime-r.md?view=sql-server-linux-ver15&preserve-view=true)
26
26
27
-
<aname="pre_install_checklist"> </a>
28
-
29
27
## Pre-install checklist
30
28
31
29
+[SQL Server 2019 for Windows (Cumulative Update 3 onwards).](../../database-engine/install-windows/install-sql-server.md)
@@ -36,7 +34,7 @@ This article describes how to install a custom runtime for running R scripts wit
36
34
37
35
## Add SQL Server Language Extensions for Windows
38
36
39
-
> [!Note]
37
+
> [!NOTE]
40
38
>For Machine Learning Services using SQL Server 2019, the extensibility framework for language extensions with the Launchpad service is already installed and you can skip this step.
41
39
42
40
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.
@@ -68,23 +66,21 @@ Complete the setup for SQL Server 2019.
68
66
69
67
1. After setup is complete, if you're instructed to restart the computer, do so now. It's important to read the message from the Installation Wizard when you've finished with Setup. For more information, see [View and Read SQL Server Setup Log Files](https://docs.microsoft.com/sql/database-engine/install-windows/view-and-read-sql-server-setup-log-files).
70
68
71
-
72
69
## Install R
73
70
74
-
> [!Note]
75
-
>For SQL Machine Learning Services, R is already installed in the **R_SERVICES** folder of your SQL Server instance e.g. "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\R_SERVICES". If you want to keep using this path as your R_HOME, skip to the next step of installing Rcpp. Otherwise, if you want to use a different runtime of R, continue below to install it.
71
+
> [!NOTE]
72
+
>For SQL Machine Learning Services, R is already installed in the **R_SERVICES** folder of your SQL Server instance e.g. `C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\R_SERVICES`. If you want to keep using this path as your R_HOME, skip to the next step of installing Rcpp. Otherwise, if you want to use a different runtime of R, continue below to install it.
76
73
77
-
[Complete installation of R (>= 3.3)](https://cran.r-project.org/bin/windows/base/) and note the path where it's installed. This path is your **R_HOME**. For example, as shown below, R_HOME is "C:\Program Files\R\R-4.0.2"
74
+
[Install R (3.3 or higher)](https://cran.r-project.org/bin/windows/base/) and note the path where it's installed. This path is your **R_HOME**. For example, as shown below, R_HOME is `C:\Program Files\R\R-4.0.2`

111
107
112
108
2. Update the **PATH** environment variable.
113
-
+Append the path to **R.dll** to the system **PATH** environment variable. To do that, select **PATH** then **Edit** and add %R_HOME%\bin\x64 to the list of paths.
109
+
Append the path to **R.dll** to the system **PATH** environment variable. To do that, select **PATH** then **Edit** and add %R_HOME%\bin\x64 to the list of paths.
114
110
115
111

116
112
117
113
3. Select **OK** to close remaining windows.
118
114
119
-
As an alternative, to set these environment variables from an *elevated* command prompt, run the following commands. Make sure to use the custom R installation path.
115
+
As an alternative, to set these environment variables from an *elevated* command prompt, run the following commands. Make sure to use the custom R installation path.
## Grant access to the custom R installation folder
127
123
128
-
> [!Note]
124
+
> [!NOTE]
129
125
>If you have installed R in the default location of **C:\Program Files\R\R-version**, you can skip this step.
130
126
131
-
Run the **icacls** commands from a new *elevated* command prompt to grant READ & EXECUTE access to the **SQL Server Launchpad Service user name** and SID **S-1-15-2-1** (**ALL APPLICATION PACKAGES**). The launchpad service user name is of the form `NT Service\MSSQLLAUNCHPAD$INSTANCENAME` where INSTANCENAME is the instance name of your SQL Server. The commands will recursively grant access to all files and folders under the given directory path.
127
+
Run the **icacls** commands from a new *elevated* command prompt to grant READ & EXECUTE access to the **SQL Server Launchpad Service user name** and SID **S-1-15-2-1** (**ALL APPLICATION PACKAGES**). The launchpad service user name is of the form `NT Service\MSSQLLAUNCHPAD$INSTANCENAME` where `INSTANCENAME` is the instance name of your SQL Server.
132
128
133
-
Append the instance name to MSSQLLAUNCHPAD (`MSSQLLAUNCHPAD$INSTANCENAME`). In this example, INSTANCENAME is the default instance `MSSQLSERVER`.
129
+
The commands will recursively grant access to all files and folders under the given directory path.
130
+
131
+
Append the instance name to `MSSQLLAUNCHPAD` (`MSSQLLAUNCHPAD$INSTANCENAME`). In this example, `INSTANCENAME` is the default instance `MSSQLSERVER`.
134
132
135
133
1. Give permissions to **SQL Server Launchpad Service user name**
>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.
147
145
148
146
## Restart SQL Server Launchpad service
149
147
150
-
Find the name of the SQL Server Launchpad Service. It is of the form MSSQLLAUCHPAD$INSTANCENAME where INSTANCENAME is the instance name of your SQL Server. By default, the name is MSSQLLAUNCHPAD$MSSQLSERVER.
148
+
Find the name of the SQL Server Launchpad Service. It is of the form `MSSQLLAUCHPAD$INSTANCENAME` where `INSTANCENAME` is the instance name of your SQL Server. By default, the name is `MSSQLLAUNCHPAD$MSSQLSERVER`.
151
149
152
-
From an *elevated* command prompt, run the following commands. Make sure to replace MSSQLLAUNCHPAD$MSSQLSERVER with the name found above. In this example, INSTANCENAME is the default instance `MSSQLSERVER`.
150
+
From an *elevated* command prompt, run the following commands. Make sure to replace `MSSQLLAUNCHPAD$MSSQLSERVER` with the name found above. In this example, `INSTANCENAME` is the default instance `MSSQLSERVER`.
153
151
154
152
```CMD
155
153
net stop MSSQLLAUNCHPAD$MSSQLSERVER
@@ -168,7 +166,7 @@ Register this R language extension with [CREATE EXTERNAL LANGUAGE](../../t-sql/s
168
166
169
167
Modify the path in this statement to reflect the location of the downloaded language extension zip file (R-lang-extension.zip) from above.
170
168
171
-
> [!Note]
169
+
> [!NOTE]
172
170
>**R** is a reserved word. Use a different name for the external language e.g. myR.
173
171
174
172
```sql
@@ -185,8 +183,6 @@ You can install SQL Server on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterp
185
183
> [!NOTE]
186
184
> This article describes how to install a custom runtime for R on Linux. To install on Windows, see the [Install an R custom for SQL Server on Windows](custom-runtime-r.md?view=sql-server-ver15&preserve-view=true)
187
185
188
-
<aname="pre_install_checklist"> </a>
189
-
190
186
## Pre-install checklist
191
187
192
188
+[SQL Server 2019 for Linux (Cumulative Update 3 onwards).](../../linux/sql-server-linux-setup.md)
@@ -198,14 +194,15 @@ Before you install SQL Server on Linux, you must configure a Microsoft repositor
198
194
199
195
## Add SQL Server Language Extensions for Linux
200
196
201
-
> [!Note]
197
+
> [!NOTE]
202
198
>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.
203
199
204
200
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.
205
201
206
202
### Ubuntu
207
203
> [!Tip]
208
204
> If possible, `sudo apt-get update` to refresh packages on the system prior to installation. Ubuntu might not have the https apt transport option. To install it, use `sudo apt-get install apt-transport-https`.
>For SQL Machine Learning Services, R is already installed in **/opt/microsoft/ropen/3.5.2/lib64/R**. If you want to keep using this path as your R_HOME, skip to the next step of installing **Rcpp**. Otherwise, if you want to use a different runtime of R, you first need to remove **microsoft-r-open-mro** before continuing to install a new version. Example for Ubuntu:
230
-
>```bash
231
-
>sudo apt remove microsoft-r-open-mro-3.5.2
232
-
>```
225
+
>[!NOTE]
226
+
>For SQL Machine Learning Services, R is already installed in `/opt/microsoft/ropen/3.5.2/lib64/R`. If you want to keep using this path as your R_HOME, skip to the next step of **installing Rcpp**.
233
227
234
-
[Complete installation of R (>= 3.3)](https://cran.r-project.org/bin/linux/) by following the instructions foryour respective linux platform. By default, R is installedin**/usr/lib/R**. This path is your **R_HOME**. If you install R in a different location, take note of that path as your R_HOME.
228
+
If you want to use a different runtime of R, you first need to remove `microsoft-r-open-mro` before continuing to install a new version. Example for Ubuntu:
229
+
230
+
```bash
231
+
sudo apt remove microsoft-r-open-mro-3.5.2
232
+
```
233
+
234
+
Follow the [instructions](https://cran.r-project.org/bin/linux/) to complete the installation of R (3.3 or later) for your respective linux platform. By default, R is installed in **/usr/lib/R**. This path is your **R_HOME**. If you install R in a different location, take note of that path as your R_HOME.
235
235
236
236
Example instructions for Ubuntu. Change the repository URL below for your version of R.
237
237
@@ -251,10 +251,10 @@ sudo apt-get update
251
251
sudo apt-get -y install r-base-core
252
252
```
253
253
254
-
In all the instructions below, ${R_HOME} is the path to your R installation as noted here and should be replaced with that value.
255
-
256
254
## Install Rcpp package
257
255
256
+
In the instructions below, ${R_HOME} is the path to your R installation.
257
+
258
258
+ Locate the R binary in ${R_HOME}/bin. By default, it is in **/usr/lib/R/bin**.
259
259
260
260
+ Start R
@@ -263,30 +263,28 @@ In all the instructions below, ${R_HOME} is the path to your R installation as n
263
263
sudo ${R_HOME}/bin/R
264
264
```
265
265
266
-
+ In this *elevated* R prompt (${R_HOME}/bin/R), run the following script. to install the **Rcpp** package in the ${R_HOME}/library folder.
266
+
+ In this *elevated* R prompt (${R_HOME}/bin/R), run the following script. to install the `Rcpp` package in the ${R_HOME}/library folder.
>If you have installed R in the default location of **/usr/lib/R**, you can skip this section.
276
276
277
277
#### Update the environment variables
278
278
279
-
1. Add the R_HOME environment variable to mssql-launchpadd service config.
280
-
281
-
+ Edit **mssql-launchpadd** service.
279
+
1. Edit the mssql-launchpadd service to add the R_HOME environment variable to the file `/etc/systemd/system/mssql-launchpadd.service.d/override.conf`
282
280
283
281
```bash
284
282
sudo systemctl edit mssql-launchpadd
285
283
```
286
284
287
-
+ Insert the following text in the **/etc/systemd/system/mssql-launchpadd.service.d/override.conf** file that opens. Set value of R_HOME to the custom R installation path.
285
+
+ Insert the following text in the `/etc/systemd/system/mssql-launchpadd.service.d/override.conf` file that opens. Set value of R_HOME to the custom R installation path.
288
286
289
-
```vi editor
287
+
```text
290
288
[Service]
291
289
Environment="R_HOME=/path/to/installation/of/R"
292
290
```
@@ -326,7 +324,7 @@ sudo /opt/mssql/bin/mssql-conf set extensibility.datadirectories /path/to/instal
326
324
327
325
#### Restart mssql-launchpadd service
328
326
329
-
> [!Note]
327
+
> [!NOTE]
330
328
>If you have installed R in the default location of **/usr/lib/R**, you can skip this step.
331
329
332
330
```bash
@@ -343,7 +341,7 @@ Register this R language extension with [CREATE EXTERNAL LANGUAGE](../../t-sql/s
343
341
344
342
Modify the path in this statement to reflect the location of the downloaded language extension zip file (R-lang-extension.zip) from above.
345
343
346
-
> [!Note]
344
+
> [!NOTE]
347
345
>**R** is a reserved word. Use a different name for the external language e.g. myR.
0 commit comments