Install SQL Server machine learning R and Python components from the command line

APPLIES TO: yesSQL Server (Windows only) noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

This article provides instructions for intalling SQL Server machine learning components from a command line:

You can specify silent, basic, or full interaction with the Setup user interface. This article supplements Install SQL Server from the Command Prompt, covering the parameters unique to R and Python machine learning components.

Pre-install checklist

  • Run commands from an elevated command prompt.

  • A database engine instance is required for in-database installations. You cannot install just R or Python features, although you can add them incrementally to an existing instance. If you want just R and Python without the database engine, install the standalone server.

  • Do not install on a failover cluster. The security mechanism used for isolating R and Python processes is not compatible with a Windows Server failover cluster environment.

  • Do not install on a domain controller. The Machine Learning Services portion of setup will fail.

  • Avoid installing standalone and in-database instances on the same computer. A standalone server will compete for the same resources, undermining the performance of both installations.

Command line arguments

The FEATURES argument is required, as are licensing term agreements.

When installing through the command prompt, SQL Server supports full quiet mode by using the /Q parameter, or Quiet Simple mode by using the /QS parameter. The /QS switch only shows progress, does not accept any input, and displays no error messages if encountered. The /QS parameter is only supported when /Action=install is specified.

Arguments Description
/FEATURES = AdvancedAnalytics Installs the in-database version: SQL Server 2017 Machine Learning Services (In-Database) or SQL Server 2016 R Services (In-Database).
/FEATURES = SQL_INST_MR Applies to SQL Server 2017 only. Pair this with AdvancedAnalytics. Installs the (In-Database) R feature, including Microsoft R Open and the proprietary R packages. The SQL Server 2016 R Services feature is R-only, so there is no parameter for that release.
/FEATURES = SQL_INST_MPY Applies to SQL Server 2017 only. Pair this with AdvancedAnalytics. Installs the (In-Database) Python feature, including Anaconda and the proprietary Python packages.
/FEATURES = SQL_SHARED_MR Installs the R feature for the standalone version: SQL Server 2017 Machine Learning Server (Standalone) or SQL Server 2016 R Server (Standalone). A standalone server is a "shared feature" not bound to a database engine instance.
/FEATURES = SQL_SHARED_MPY Applies to SQL Server 2017 only. Installs the Python feature for the standalone version: SQL Server 2017 Machine Learning Server (Standalone). A standalone server is a "shared feature" not bound to a database engine instance.
/IACCEPTROPENLICENSETERMS Indicates you have accepted the license terms for using the open source R components.
/IACCEPTPYTHONLICENSETERMS Indicates you have accepted the license terms for using the Python components.
/IACCEPTSQLSERVERLICENSETERMS Indicates you have accepted the license terms for using SQL Server.
/MRCACHEDIRECTORY For offline setup, sets the folder containing the R component CAB files.
/MPYCACHEDIRECTORY For offline setup, sets the folder containing the Python component CAB files.

In-database instance installations

In-database analytics are available for database engine instances, required for adding the AdvancedAnalytics feature to your installation. You can install a database engine instance with advanced analytics, or add it to an existing instance.

To view progress information without the interactive on-screen prompts, use the /qs argument.

Important

After installation, two additional configuration steps remain. Integration is not complete until these tasks are performed. See Post-installation tasks for instructions.

SQL Server 2017: database engine, advanced analytics with Python and R

For a concurrent installation of the database engine instance, provide the instance name and an administrator (Windows) login. Include features for installing core and language components, as well as acceptance of all licensing terms.

Setup.exe /qs /ACTION=Install /FEATURES=SQLEngine,ADVANCEDANALYTICS,SQL_INST_MR,SQL_INST_MPY
/INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="<Windows-username>" 
/IACCEPTSQLSERVERLICENSETERMS /IACCEPTROPENLICENSETERMS /IACCEPTPYTHONLICENSETERMS

This the same command, but with a SQL Server login on a database engine using mixed authentication.

Setup.exe /q /ACTION=Install /FEATURES=SQLEngine,ADVANCEDANALYTICS,SQL_INST_MR,SQL_INST_MPY
/INSTANCENAME=MSSQLSERVER /SECURITYMODE=SQL /SAPWD="%password%" /SQLSYSADMINACCOUNTS="<sql-username>" 
/IACCEPTSQLSERVERLICENSETERMS /IACCEPTROPENLICENSETERMS /IACCEPTPYTHONLICENSETERMS

This example is Python only, showing that you can add one language by omitting a feature.

Setup.exe /qs /ACTION=Install /FEATURES=SQLEngine,ADVANCEDANALYTICS,SQL_INST_MPY 
/INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="<username>" 
/IACCEPTSQLSERVERLICENSETERMS  /IACCEPTPYTHONLICENSETERMS

SQL Server 2016: database engine and advanced analytics with R

This command is identical to SQL Server 2017, but without the Python elements, which are not available in SQL Server 2016 setup.

Setup.exe /qs /ACTION=Install /FEATURES=SQLEngine,ADVANCEDANALYTICS,SQL_INST_MR
/INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="<Windows-username>" 
/IACCEPTSQLSERVERLICENSETERMS /IACCEPTROPENLICENSETERMS 

Post-install configuration (required)

Applies to in-database installations only.

When setup is finished, you have a database engine instance with R and Python, the Microsoft R and Python packages, Microsoft R Open, Anaconda, tools, samples, and scripts that are part of the distribution.

Two more tasks are required to complete the installation:

  1. Restart the database engine service.

  2. Enable external scripts before you can use the feature. Follow the instructions in Install SQL Server 2017 Machine Learning Services (In-Database) as your next step.

For SQL Server 2016, use this article instead Install SQL Server 2016 R Services (In-Database).

Add advanced analytics to an existing database engine instance

When adding in-database advanced analytics to an existing database engine instance, provide the instance name. For example, if you previously installed a SQL Server 2017 database engine and Python, you could use this command to add R.

Setup.exe /qs /ACTION=Install /FEATURES=SQL_INST_MR /INSTANCENAME=MSSQLSERVER 
/IACCEPTSQLSERVERLICENSETERMS  /IACCEPTROPENLICENSETERMS

Silent install

A silent installation suppresses the check for .cab file locations. For this reason, you must specify the location where .cab files are to be unpacked. You can the temp directory for this.

Setup.exe /q /ACTION=Install /FEATURES=SQLEngine,ADVANCEDANALYTICS,SQL_INST_MR,SQL_INST_MPY 
/INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="<username>" 
/IACCEPTSQLSERVERLICENSETERMS /IACCEPTROPENLICENSETERMS /IACCEPTPYTHONLICENSETERMS 
/MRCACHEDIRECTORY=%temp% /MPYCACHEDIRECTORY=%temp%

Standalone server installations

A standalone server is a "shared feature" not bound to a database engine instance. The following examples show valid syntax for both releases.

SQL Server 2017 supports Python and R on a standalone server:

Setup.exe /q /ACTION=Install /FEATURES=SQL_SHARED_MR,SQL_SHARED_MPY  
/IACCEPTROPENLICENSETERMS /IACCEPTPYTHONLICENSETERMS /IACCEPTSQLSERVERLICENSETERMS

SQL Server 2016 is R-only:

Setup.exe /q /ACTION=Install /FEATURES=SQL_SHARED_MR 
/IACCEPTROPENLICENSETERMS /IACCEPTSQLSERVERLICENSETERMS

When setup is finished, you have a server, Microsoft packages, open-source distributions of R and Python, tools, samples, and scripts that are part of the distribution.

To open an R console window, go to \Program files\Microsoft SQL Server\140 (or 130)\R_SERVER\bin\x64 and double-click RGui.exe. New to R? Try this tutorial: Basic R commands and RevoScaleR functions: 25 common examples.

To open a Python command, go to \Program files\Microsoft SQL Server\140\PYTHON_SERVER\bin\x64 and double-click python.exe.

Get help

Need help with installation or upgrade? For answers to common questions and known issues, see the following article:

To check the installation status of the instance and fix common issues, try these custom reports.

Next steps

R developers can get started with some simple examples, and learn the basics of how R works with SQL Server. For your next step, see the following links:

Python developers can learn how to use Python with SQL Server by following these tutorials:

To view examples of machine learning that are based on real-world scenarios, see Machine learning tutorials.