MS SQL server 2019 connection to Python, broken after clone to new computer - Unable to communicate with the runtime for 'Python' script

Joshua Lindsay 0 Reputation points
2023-07-23T03:23:25.6433333+00:00

My SQL 2019 database queries from within SSMS started throwing errors re communicating with the python runtime, immediately after cloning the operating system solid state drive to a new SSD and installing it into a new computer.

This occurs when trying to run an external python script with

EXEC sp_execute_external_script

The error is:

Msg 39012, Level 16, State 14, Line 2 Unable to communicate with the runtime for 'Python' script for request id: F3A80B16-DEDC-401B-B16A-0D9D8E163CCC. Please check the requirements of 'Python' runtime.

I cloned the computer using Acronis True Image, and the clone completed successfully, with no reported bad sectors or any other errors. I am running Windows 10 Home edition 22H2 with all window updates installed. I am running Microsoft SQL Server 2019 Developer Edition 15.0.2101.7, and using SSMS version 18.8. Running Python 3.7.1. I am running the queries on the actual server itself.

Immediately after cloning, the drive booted successfully on the new computer. I ran Windows update to install any new drivers, and the drivers were the only new updates, as I had previously installed all available updates on the old drive.

I then tested my SQL server database, which is when I discovered this error.

I checked that enable external scripts was enabled, which it is.

I ran some basic code to test the functionality of Python within SQL, and it came up with the same error. That code was:

EXEC sp_execute_external_script
@language = N'Python',
@script = N'
import sys
'

I have tried to re clone the system again, with the same results.

I have ran the python version that SQL server 2019 installed at the following location manually, and it runs normally:

C:\Program Files\Microsoft SQL Server\MSSQL15.servername\PYTHON_SERVICES

I checked the system event logs and there is a python error:

Faulting application name: python.exe, version: 3.7.1150.1013, time stamp: 0x5c0f4332 Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 Exception code: 0xc0000005 Fault offset: 0x0000000000000000 Faulting process id: 0x45ac Faulting application start time: 0x01d9bc2d2ecbebd4 Faulting application path: C:\Program Files\Microsoft SQL Server\MSSQL15.servername\PYTHON_SERVICES\python.exe Faulting module path: unknown Report Id: ec2f200f-47ac-433b-83f0-0d1b8bc16033 Faulting package full name: Faulting package-relative application ID:

After reading numerous articles, I've tried enabling Named Pipes from within the SQL Server Configuration Manager, with no change.

I've tried granting full access to the MSSQLLauchpad$Servername account on the Python Services folder located in

"C:\Program Files\Microsoft SQL Server\MSSQL15.servername"

and restarting the server, without success.

I have tested the R runtime with a basic "hello world" script, and that runs successfully.

One article suggested reinstalling Numpy, which I did as well, on the python instance.

Another article suggested loading BIOS defaults, which I did, without any change.

I also added the scripts folder path, located in the folder above, to the system PATH.

I have edited the pythonlauncher.config file to change the working directory to: C:\Program Files\Microsoft SQL Server\MSSQL15.servername\MSSQL\ExtensibilityData

I have upgraded server 2019 to 2022.

I have upgraded SSMS from 18.8 to 19.x.

I have re-cloned twice.

I have also gone back to the original drive, on the original computer, and confirmed that I am not getting that error at all, either with my code, or the test code.

I asked this question on Stack overflow, but haven't had any responses, so thought I would post here too.

Any suggestions greatly appreciated.

SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-07-23T08:05:26.2533333+00:00

    I am running Microsoft SQL Server 2019 Developer Edition 15.0.2101.7

    That's an old build of SQL 2019, and you should download and install the most recent Cumulative Update.

    Although it seems from the later in the text that you have since upgraded to SQL 2022. Then again, the same thing applies there. You should always download and install the CUs. Maybe not exactly everyone, but don't fall more than 3-4 builds behind. The latest CU for SQL 2022 is here.

    As for the actual problem, I don't know, but it seems like a case of when taking a shortcut can make things take longer time. I would uninstall the lot and re-install. Well, I might first try the Repair option, but I would not have much faith in that.

    As for what you tried: SSMS is just a tool and has nothing to do with it. Adding numpy is not going to change things. It seems from the error message that Python runs into an access violation. Why, I don't know, but may there is something hidden which goes not go well with the disk cloning.


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.