Skip to content

Commit 7be4d7e

Browse files
authored
Merge pull request #17134 from cawrites/custom-edit
Custom edit
2 parents 2526e14 + f6f7316 commit 7be4d7e

2 files changed

Lines changed: 50 additions & 60 deletions

File tree

docs/machine-learning/install/custom-runtime-python.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ Install the [pandas](https://pandas.pydata.org/) package for Python from an *ele
8484
python.exe -m pip install pandas
8585
```
8686

87-
8887
## Update the system environment variables
8988

9089
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
10099

101100
![Create PYTHONHOME system variable.](../install/media/sys-pythonhome.png)
102101

103-
104102
## Grant access to the custom Python installation folder
105103

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.
107105

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`.
109107

110108
1. Give permissions to **SQL Server Launchpad Service user name**
111109

@@ -176,7 +174,7 @@ When you install SQL Server on Linux, you must configure a Microsoft repository.
176174
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.
177175

178176
### Ubuntu
179-
> [!Tip]
177+
> [!TIP]
180178
> 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`.
181179
182180
```bash
@@ -215,21 +213,19 @@ sudo python3.7 -m pip install pandas -t /usr/lib/python3.7/dist-packages
215213
## Using a custom installation of Python 3.7
216214

217215
> [!NOTE]
218-
> 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).
219217
220218
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.
221219

222220
#### Update the environment variables
223221

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`
227223

228224
```bash
229225
sudo systemctl edit mssql-launchpadd
230226
```
231227

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.
233229

234230
```vi
235231
[Service]
@@ -238,23 +234,23 @@ If you built your own version of Python 3.7, follow the following steps so that
238234

239235
+ Save and close.
240236

241-
2. Make sure **libpython3.7m.so.1.0** can be loaded.
237+
2. Make sure `libpython3.7m.so.1.0` can be loaded.
242238

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`.
244240

245241
```bash
246242
sudo vi /etc/ld.so.conf.d/custom-python.conf
247243
```
248244

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.
250246

251247
```vi
252248
/path/to/installation/of/python3.7/lib
253249
```
254250

255251
+ Save and close the new file.
256252

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.
258254

259255
```bash
260256
sudo ldconfig
@@ -274,9 +270,6 @@ sudo /opt/mssql/bin/mssql-conf set extensibility.datadirectories /path/to/instal
274270
```bash
275271
sudo systemctl restart mssql-launchpadd
276272
```
277-
278-
279-
280273
## <a name="download-python-linux"></a> Download Python language extension
281274

282275
Download the zip file containing the Python language extension (**python-lang-extension.zip**) from [here.](**GitHub link goes here**)
@@ -299,7 +292,6 @@ GO
299292

300293
::: moniker-end
301294

302-
303295
## Enable external script execution in SQL Server
304296

305297
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)

docs/machine-learning/install/custom-runtime-r.md

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ This article describes how to install a custom runtime for running R scripts wit
2424
> [!NOTE]
2525
> 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)
2626
27-
<a name="pre_install_checklist"> </a>
28-
2927
## Pre-install checklist
3028

3129
+ [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
3634

3735
## Add SQL Server Language Extensions for Windows
3836

39-
> [!Note]
37+
> [!NOTE]
4038
>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.
4139
4240
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.
6866

6967
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).
7068

71-
7269
## Install R
7370

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.
7673
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`
7875

7976
![Install Custom R](../install/media/custom-r-installation.png)
8077

81-
> [!Note]
82-
>In all the instructions below, %R_HOME% is the path to your R installation as noted above and should be replaced with that value.
78+
> [!NOTE]
79+
>In all the instructions below, `%R_HOME%` is the path to your R installation as noted above and should be replaced with that value.
8380
8481
## Install Rcpp package
8582

86-
+ Locate the R executable in %R_HOME%\bin. By default, it is in *C:\Program Files\R\R-4.0.2\bin*.
87-
83+
+ Locate the R executable in %R_HOME%\bin. By default, it is in `C:\Program Files\R\R-4.0.2\bin`.
8884

8985
+ Start R from an *elevated* command prompt:
9086

@@ -110,13 +106,13 @@ install.packages("Rcpp", lib="%R_HOME%/library");
110106
![Create R_HOME system environment variable.](../install/media/sys-env-r-home.png)
111107

112108
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.
114110

115111
![Append to PATH system environment variable.](../install/media/sys-env-path-r.png)
116112

117113
3. Select **OK** to close remaining windows.
118114

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.
120116

121117
```CMD
122118
setx /m R_HOME "path\to\installation\of\R"
@@ -125,31 +121,33 @@ setx /m PATH "path\to\installation\of\R\bin\x64;%PATH%"
125121

126122
## Grant access to the custom R installation folder
127123

128-
> [!Note]
124+
> [!NOTE]
129125
>If you have installed R in the default location of **C:\Program Files\R\R-version**, you can skip this step.
130126
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.
132128

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`.
134132

135133
1. Give permissions to **SQL Server Launchpad Service user name**
136134

137135
```cmd
138136
icacls "%R_HOME%" /grant "NT Service\MSSQLLAUNCHPAD$MSSQLSERVER":(OI)(CI)RX /T
139-
137+
```
140138
2. Give permissions to **SID S-1-15-2-1**
141139
142140
```cmd
143141
icacls "%R_HOME%" /grant *S-1-15-2-1:(OI)(CI)RX /T
144-
145-
>[!Note]
142+
```
143+
>[!NOTE]
146144
>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.
147145
148146
## Restart SQL Server Launchpad service
149147
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`.
151149
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`.
153151
154152
```CMD
155153
net stop MSSQLLAUNCHPAD$MSSQLSERVER
@@ -168,7 +166,7 @@ Register this R language extension with [CREATE EXTERNAL LANGUAGE](../../t-sql/s
168166

169167
Modify the path in this statement to reflect the location of the downloaded language extension zip file (R-lang-extension.zip) from above.
170168

171-
> [!Note]
169+
> [!NOTE]
172170
>**R** is a reserved word. Use a different name for the external language e.g. myR.
173171
174172
```sql
@@ -185,8 +183,6 @@ You can install SQL Server on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterp
185183
> [!NOTE]
186184
> 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)
187185
188-
<a name="pre_install_checklist"> </a>
189-
190186
## Pre-install checklist
191187

192188
+ [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
198194

199195
## Add SQL Server Language Extensions for Linux
200196

201-
> [!Note]
197+
> [!NOTE]
202198
>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.
203199
204200
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.
205201

206202
### Ubuntu
207203
> [!Tip]
208204
> 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`.
205+
209206
```bash
210207
# Install as root or sudo
211208
sudo apt-get install mssql-server-extensibility
@@ -225,13 +222,16 @@ sudo zypper install mssql-server-extensibility
225222

226223
## Install R
227224

228-
>[!Note]
229-
>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**.
233227
234-
[Complete installation of R (>= 3.3)](https://cran.r-project.org/bin/linux/) by following the instructions 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.
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.
235235

236236
Example instructions for Ubuntu. Change the repository URL below for your version of R.
237237

@@ -251,10 +251,10 @@ sudo apt-get update
251251
sudo apt-get -y install r-base-core
252252
```
253253

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-
256254
## Install Rcpp package
257255

256+
In the instructions below, ${R_HOME} is the path to your R installation.
257+
258258
+ Locate the R binary in ${R_HOME}/bin. By default, it is in **/usr/lib/R/bin**.
259259

260260
+ Start R
@@ -263,30 +263,28 @@ In all the instructions below, ${R_HOME} is the path to your R installation as n
263263
sudo ${R_HOME}/bin/R
264264
```
265265

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.
267267

268268
```R
269269
install.packages("Rcpp", lib = "${R_HOME}/library");
270270
```
271271

272272
## Using a custom installation of R
273273

274-
> [!Note]
274+
> [!NOTE]
275275
>If you have installed R in the default location of **/usr/lib/R**, you can skip this section.
276276
277277
#### Update the environment variables
278278

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`
282280

283281
```bash
284282
sudo systemctl edit mssql-launchpadd
285283
```
286284

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.
288286

289-
```vi editor
287+
```text
290288
[Service]
291289
Environment="R_HOME=/path/to/installation/of/R"
292290
```
@@ -326,7 +324,7 @@ sudo /opt/mssql/bin/mssql-conf set extensibility.datadirectories /path/to/instal
326324

327325
#### Restart mssql-launchpadd service
328326

329-
> [!Note]
327+
> [!NOTE]
330328
>If you have installed R in the default location of **/usr/lib/R**, you can skip this step.
331329

332330
```bash
@@ -343,7 +341,7 @@ Register this R language extension with [CREATE EXTERNAL LANGUAGE](../../t-sql/s
343341

344342
Modify the path in this statement to reflect the location of the downloaded language extension zip file (R-lang-extension.zip) from above.
345343

346-
> [!Note]
344+
> [!NOTE]
347345
>**R** is a reserved word. Use a different name for the external language e.g. myR.
348346

349347
```sql

0 commit comments

Comments
 (0)