在SQL Server 2017中启用Python



我已在下面执行:

 EXEC sp_configure 'external scripts enabled', 1
 RECONFIGURE WITH OVERRIDE

从消息看来,一切成功:

 Configuration option 'external scripts enabled' changed from 1 to 1. Run the RECONFIGURE statement to install.

但是,在下面执行脚本时,显示错误:

exec sp_execute_external_script 
@language =N'Python',
@script=N'OutputDataSet = InputDataSet
print("Input data is {0}".format(InputDataSet))', 
@input_data_1 = N'SELECT 1 as col'

错误:

   Msg 39023, Level 16, State 1, Procedure sp_execute_external_script, Line 1 [Batch Start Line 7]
 'sp_execute_external_script' is disabled on this instance of SQL Server. Use sp_configure 'external scripts enabled' to enable it.

执行时:exec sp_configure

它显示"启用外部脚本" run_value为0

当我通过运行更新更新"运行值"查询时:

 update sys.configurations set value_in_use = 1
 where name like 'external scripts enabled'

获取错误:

  Ad hoc updates to system catalogs are not allowed.

这是系统详细信息(来自SSMS帮助 ->关于(:

  SQL Server Management Studio          15.0.18118.0
  Microsoft Analysis Services Client Tools  15.0.1300.131
  Microsoft Data Access Components (MDAC)   10.0.17134.1
  Microsoft MSXML                       3.0 6.0 
  Microsoft Internet Explorer           9.11.17134.0
  Microsoft .NET Framework              4.0.30319.42000
  Operating System                      6.3.17134
Microsoft SQL Server 2017 (RTM-CU14) (KB4484710) - 14.0.3076.1 (X64) 
Mar 12 2019 19:29:19 
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Windows 10 Home 10.0 <X64> (Build 17134: )

此外,尝试从此处安装SQL Server最新更新(https://www.microsoft.com/en-us/download/details.aspx?id=56128(。

Python无法安装。

如何解决此问题并在SQL Server 2017上运行Python?我需要安装任何SQL Server服务包吗?请建议。谢谢。

  1. 检查文件夹" python_services"及其内容在路径下可用:

[drivename]: program Files Microsoft SQL Server MSSQL14。[your_instance_name] python_services

  1. 如果不存在,请通过以下链接进行安装:https://learn.microsoft.com/en-us/sql/advanced-analytics/install/sql-machine-learning-services-windows-install?view = sql-server-server-2017

  2. 如果存在上述文件夹,则需要通过运行sp_configure proc,然后重新启动SQL Server实例,将"启用外部脚本"值设置为1。3.1。右键单击您的SQL Server,然后单击"重新启动"。

  3. 成功重新启动后,检查已配置的值启用/禁用:

从sys.sysconfigures select * comment ='允许执行外部脚本'去

"值"列应为1。

  1. 如果将"值"列设置为1,则您可以执行外部脚本,例如SSMS中的" R"或" Python"。

尝试在下面运行,看看两个都没有任何错误返回结果:

 exec sp_execute_external_script
    @language=N'Python'
   , @script=N'
   print("Hello World")'
 go
exec sp_execute_external_script
   @language=N'R'
 , @script=N'print(R.version)'
 go

在SQL Server 2017上,运行EXEC sp_configure 'external scripts enabled', 1 RECONFIGURE WITH OVERRIDE之后,您需要重新启动实例。

最新更新