Errors when calling Python in SQL 2019 via sp_execute_external_script

Mantini, Ronald M 6 Reputation points
2021-07-07T22:08:42.343+00:00

Just completed a fresh stand alone install of **SQL 2019 developer edition **where we chose to also install the Python option under Machine Learning Services and Languages. The install was completed successfully.

When calling Python from SSMS using sp_execute_external_script, I get the below error.

Msg 39012, Level 16, State 14, Line 0
Unable to communicate with the runtime for 'Python' script for request id: BFCF876F-40C8-4DD8-B925-2B85DC7FF3F9. Please check the requirements of 'Python' runtime.
At the same time in the event viewer I see these errors around bxlserver.exe

Faulting application name: BxlServer.exe, version: 9.2.0.0, time stamp: 0x5d6469b7Faulting module name: KERNELBASE.dll, version: 10.0.17763.1911, time stamp: 0x206fb2f7Exception code: 0xc06d007eFault offset: 0x0000000000039689Faulting process id: 0x19f8Faulting application start time: 0x01d76d2b6acb7b42Faulting application path: D:\Program Files\Microsoft SQL Server\MSSQL15.SQL01\PYTHON_SERVICES\lib\site-packages\revoscalepy\rxLibs\BxlServer.exeFaulting module path: C:\Windows\System32\KERNELBASE.dllReport Id: 5f0d44a2-cef3-4b2f-9584-d704c671cde1Faulting package full name: Faulting package-relative application ID:

A lot of info on the first error is available online, I have tried most with no success yet.

The 'pythonlauncher.log' has this error repeated 7 times every time I try to run the script from ssms:
[2021-07-07 21:33:26.813][000028DC][0000222C][Error] Process::TryTerminate failed with error code: 5

The SQL Server Error Log shows this error:
Message
Failed to retrieve the connection from satellite {CEA94CF6-B944-420F-BF45-5FB8C667761C} after 60000 MilliSeconds. ErrorCode: 0x80040001.

Measures I have already taken include 'enabling' sp_execute_external_script via sp_configure and granting the domain account running the SQL Launchpad Service full access to the 'python services' directory, as well as the administrators group of which our launchpad acct is already a member.
We also added the path to python.exe to the PATH environment variables. I have also applied SQL 2019 CU11 update as well as the latest Python CU.

I found this thread which seems to be the identical problem and the solution was to re-install SQL Server on the C drive. I also installed on a different drive, D for me, I can't imagine this is the only way to make this work (https://social.msdn.microsoft.com/Forums/en-US/197971e9-01e2-45c3-bac1-3a2e2dcaf685/sql-server-2019-unable-to-communicate-with-the-runtime-for-r-script-for-request-id-please?forum=sqldatabasemirroring)

Thanks in advance for any help.
Ron Mantini
Intel Corp

SQL Server Other
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Cris Zhan-MSFT 6,661 Reputation points
    2021-07-08T08:51:25.313+00:00

    Hello @Mantini, Ronald M ,

    Welcome to Microsoft Q&A!

    >When calling Python from SSMS using sp_execute_external_script, I get the below error:Msg 39012, Level 16, State 14, Line 0

    I tried to install SQL Server and machine learning service (Python) on another disk other than the C drive (the default location used by the SQL Server installation), and then I also encountered this problem when I ran any script with sp_execute_external_script in SSMS.

    What needs to be mentioned is that the SQL Server instance I installed on the C drive will not be a problem. So reinstalling the SQL Server instance on the C drive indeed is a solution.

    After some searching, I found a solution. My SQL Server is installed on the E drive (E:\SQLServer2019),the instance name is lucky.

    You need to find and open E:\SQLServer2019\MSSQL15.LUCKY\MSSQL\Binn\pythonlauncher.config, which can be opened with Notepad. If you are prompted to deny access when modify it, you need to provide "full control" permission for the current account that logs in to windows.

    Then edit this line:
    WORKING_DIRECTORY=E:\ProgramData\LUCKY\Temp-PY

    To:
    WORKING_DIRECTORY=E:\SQLServer2019\MSSQL15.LUCKY\MSSQL\ExtensibilityData

    Read the following blog to get inspired.
    https://www.sqlservercentral.com/articles/fixing-mls-python-services-to-load-the-runtime

    Best Regards,
    Cris


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.