Error using python in SQL2022: DLL load failed on import: pylink and px_call

  • I'm getting an error trying to execute python scripts inside SQL Server 2022, and would appreciate any suggestions. After following this guide (for Python only): https://tomaztsql.wordpress.com/2022/12/05/using-r-and-python-in-microsoft-sql-server-2022/

    I get the error message below any time I try to execute a python script in Sql2022, for example:

    EXEC sp_execute_external_script @script=N'import sys;print(sys.version)',@language=N'Python';

     

    The error message is:

    Msg 39012, Level 16, State 14, Line 33
    Unable to communicate with the runtime for 'Python' script for request id: 5AD43A30-AC40-48D5-BF24-C06EB3CFBEBC. Please check the requirements of 'Python' runtime.
    STDERR message(s) from external script:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\username\AppData\Local\Programs\Python\Python311\Lib\site-packages\revoscalepy\__init__.py", line 121, in <module>
        from .RxSerializable import RxMissingValues
      File "C:\Users\username\AppData\Local\Programs\Python\Python311\Lib\site-packages\revoscalepy\RxSerializable.py", line 27, in <module>
        from . rxLibs.pylink import px_call
    ImportError: DLL load failed while importing pylink: The specified module could not be found.
  • Quick question, have you asserted your python environment in the scope of the SQL Server instance and the user?

    😎

  • I don’t know what you mean. If you mean python virtual environments, I am not using any.  If you’re referring to permissions, as I understand it, SQL server’s setup process, including the revoscalepy config, sets up the user/group NT Service\MSSQLLaunchpad with correct permissions to access the folder. The entire setup is covered in the link in my original post. If there’s any additional step you think is needed, please let me know. Thank you.

  • Dose "C:\Users\username\AppData\Local\Programs\Python\Python311\Lib\site-packages\revoscalepy\RxSerializable.py" exist? Is the pylink library in the path?

    😎

    You might want to read through learn.microsoft.com/en-us/sql/machine-learning/install/custom-runtime-python?view=sql-server-ver16&pivots=platform-windows

  • Thank you. Mostly those are old installation instructions—setup changed with sql2022. I did follow the sql2022 specific part of the instructions, which is the same as given in the link in my original post.

    The rxSerializable.py file exists, and in the folder mentioned (as the error message indicates, it errored on a import line from that file).

    pylink package was not installed, but the pylink.pyd file was present in the revoscalepy\rxLibs folder. I added that to the path and it made no difference. I added the pylink library separately with pip and it made no difference.

    I guess all I can do is uninstall and reinstall python, and reconfigure revoscalepy again, but I suspect it won’t make any difference.

     

  • I discovered the problem. That revoscalepy wheel works only with Python 3.10. Somehow the guide I linked to has it working with Python 3.11, but I have no idea how.  (I put pylink.pyd in the dependency walker and it looks specifically for python310.dll.)

    So I have sql2022 integrating with python 3.10, but I don't see how to get it to work with python 3.11--and I don't see a revoscalepy wheel for python 3.11 either.

  • Heh... Had to laugh...I was just thinking that "Revo-Scalepy" (revo-sca-lepy) might make a great name for a line of blenders and food processors. 😀 😀 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Heh... Had to laugh...I was just thinking that "Revo-Scalepy" (revo-sca-lepy) might make a great name for a line of blenders and food processors. 😀 😀 😀

    "Reco-sca-lepy" would be the data processor version 😀

    😎

     

  • TechVsLife wrote:

    I discovered the problem. That revoscalepy wheel works only with Python 3.10. Somehow the guide I linked to has it working with Python 3.11, but I have no idea how.  (I put pylink.pyd in the dependency walker and it looks specifically for python310.dll.)

    So I have sql2022 integrating with python 3.10, but I don't see how to get it to work with python 3.11--and I don't see a revoscalepy wheel for python 3.11 either.

    Welcome to the world of Python and python package versions of "horror".

    😎

    When working with Python on Windows, the rule of thumb is to use the version before the last stable version, which in this case is 3.10.

  • Eirikur Eiriksson wrote:

    Jeff Moden wrote:

    Heh... Had to laugh...I was just thinking that "Revo-Scalepy" (revo-sca-lepy) might make a great name for a line of blenders and food processors. 😀 😀 😀

    "Reco-sca-lepy" would be the data processor version 😀 😎

    rofl

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • It's from Revo[lution]-Scale-Py[thon]. (Microsoft's Revolution R to scale python up and out.) But I pronounce it rev-oh-ska-leppy.  Agreed on staying one release behind in Python. It takes a while for all the third party packages to test and release for the new version, and to update their packages. (Anaconda Distro is still on 3.9! But I don't use that.)

    There is actually a torturous way to get python 3.11 working with SqlServer2022, involving modifying and building from now outdated Microsoft language extensibility source code -- but I couldn't trust it for real work. So 3.10 it is. (I think the main new feature in 3.11 is speed.)

     

     

     

  • This was removed by the editor as SPAM

  • Thanks. but that wasn’t the issue in this case (see my post above).

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply