首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >远程连接在Server机器学习服务的Python数据科学客户端的设置中失败

远程连接在Server机器学习服务的Python数据科学客户端的设置中失败
EN

Stack Overflow用户
提问于 2022-06-29 08:32:20
回答 1查看 68关注 0票数 0

我正在尝试测试Python客户端与Server机器学习服务的远程连接,遵循以下指南:https://learn.microsoft.com/en-us/sql/machine-learning/python/setup-python-client-tools-sql (第6节)。运行以下脚本

代码语言:javascript
复制
def send_this_func_to_sql():
    from revoscalepy import RxSqlServerData, rx_import
    from pandas.tools.plotting import scatter_matrix
    import matplotlib.pyplot as plt
    import io
    
    # remember the scope of the variables in this func are within our SQL Server Python Runtime
    connection_string = "Driver=SQL Server;Server=localhost\instance02;Database=testmlsiris;Trusted_Connection=Yes;"
    
    # specify a query and load into pandas dataframe df
    sql_query = RxSqlServerData(connection_string=connection_string, sql_query = "select * from iris_data")
    df = rx_import(sql_query)
    
    scatter_matrix(df)
    
    # return bytestream of image created by scatter_matrix
    buf = io.BytesIO()
    plt.savefig(buf, format="png")
    buf.seek(0)
    
    return buf.getvalue()

new_db_name = "testmlsiris"
connection_string = "driver={sql server};server=sqlrzs\instance02;database=%s;trusted_connection=yes;" 

from revoscalepy import RxInSqlServer, rx_exec

# create a remote compute context with connection to SQL Server
sql_compute_context = RxInSqlServer(connection_string=connection_string%new_db_name)

# use rx_exec to send the function execution to SQL Server
image = rx_exec(send_this_func_to_sql, compute_context=sql_compute_context)[0]

生成由rx_exec返回的以下错误消息(存储在图像变量中)

代码语言:javascript
复制
connection_string: "driver={sql server};server=sqlrzs\instance02;database=testmlsiris;trusted_connection=yes;"
num_tasks: 1
execution_timeout_seconds: 0
wait: True
console_output: False
auto_cleanup: True
packages_to_load: []
description: "sqlserver"
version: "1.0"
XXX lineno: 2, opcode: 0
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "E:\SQL\MSSQL15.INSTANCE02\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 664, in rx_sql_satellite_pool_call
    exec(inputfile.read())
  File "<string>", line 34, in <module>
  File "E:\SQL\MSSQL15.INSTANCE02\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 886, in rx_remote_call
    results = rx_resumeexecution(state_file = inputfile, patched_server_name=args["hostname"])
  File "E:\SQL\MSSQL15.INSTANCE02\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 135, in rx_resumeexecution
    return _state["function"](**_state["args"])
  File "C:\Users\username\sendtosql.py", line 2, in send_this_func_to_sql
SystemError: unknown opcode
====== sqlrzs ( process 0 ) has started run at 2022-06-29 13:47:04 W. Europe Daylight Time ======
{'local_state': {}, 'args': {}, 'function': <function send_this_func_to_sql at 0x0000020F5810F1E0>}

这里出什么问题了?脚本中的第2行只是一个导入(直接在Server上测试Python脚本时使用)。任何帮助都是非常感谢的-谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-29 14:37:17

我只是想出了原因。到今天为止,https://learn.microsoft.com/de-de/sql/machine-learning/python/setup-python-client-tools-sql?view=sql-server-ver15中的数据客户端的Python版本并不是最新版本(reoscalepyVersion9.3),而我们在Server中运行的机器学习服务版本已经是9.4.7。但是,客户端和服务器的revoscalepy库必须相同,否则反序列化会导致服务器端失败。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72798225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档