SQLServerCentral Article

Fixing MLS Python Services to Load the Runtime


Recently I went to work on a SQL Server 2017 instance and couldn't get the Python runtime to load. I'd keep getting this error:

Unable to load python runtime error

A strange error for me to see, and one that didn't quite make sense. How can the runtime not launch? However, restarting the instance still resulted in this error:

Msg 39021, Level 16, State 1, Line 8

Unable to launch runtime for 'Python' script. Please check the configuration of the 'Python' runtime.

I first checked the sp_configure, thinking that perhaps it hadn't been enabled here, but it had been.

sp_configure for external scripts

I next found a troubleshooting doc on the Microsoft site. I went through this, and things appeared to be correct, but the permissions stood out to me as a potential issue. Perhaps there is some issue.

I went to the local security policy and checked on that. I saw that the allow to log on locally was missing an account.

I went to add the group for the Python services, but it wouldn't come up. Once I clicked the type button, I could add in the Groups in the advanced object search.

Checking all object types

I added this group to the permission set.

I then restarted services, and ...

Still received the error.

Next I decided to look at the Python Services folder. I didn't see my launchpad account, so I added it here.

Python Serivces folder permissions

Note: you need to add the NT Service\ text before the account name.

Again, I restarted services, and nothing worked. There wasn't even an error in the error log, which was strange (to me). When I looked at the top, all I saw were the restart messages.

SQL Server error log

After a little more searching, I find a blog from Greg Low that seemed to fit. I read through it and saw there might be a problem with the launcher. The blog talks about R, but I think the Python runtime works in a similar manner. I checked my pythonlauncher.config and found this:


I have no idea where the path listed comes from, and I don't have a folder called SQL-SQL2017-ExtensibilityData-PY the system. I decided to do what Greg did. I created an ExtensibilityData folder under c:\Temp. I then copied in the folders from the old location, which is "C:\Program Files\Microsoft SQL Server\MSSQL14.SQL2017\MSSQL\ExtensibilityData".

I then edited the config file as shown:

Once this was done, I needed to add the Launchpad service account to the permissions, with full control. Note that copying the folders from the original location kept some permissions and I couldn't set permissions at the top layer (ExtensabilityData) and have it flow. I had to set each individual folder's permissions. There's probably a better way to do this, but I just did it manually since I was in a hurry.

I completed this, and restarted the instance. This time, things worked.

Successful script

It seems like the installations of R and Python have some issues with spaces in paths, or maybe just paths in general. There are a few posts on the Internet that also talk about permissions not being set correctly.

It really does feel like the Machine Learning Services installation and configuration on Windows is a bit of a kludge and it doesn't always work. If you want to run R or Python code in your SQL Server instance, be prepared to double check some paths and permissions, and perhaps move them around.


You rated this post out of 5. Change rating




You rated this post out of 5. Change rating