none
Python script fails on SQL Server 2017 RRS feed

  • Question

  • Hey,

    I have been doing Python 3.6 development for some time.  I am using Anaconda and my install directory is: 

    C:\Users\Charles\Anaconda3\python.exe.

    Last week I downloaded SQL Server 2017 Developer Edition and installed it on this machine (Windows 10, Intel I7 x64). The install path was 

    S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\

    I am using xgboost in my work and from a cmd shell, I ran

    S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\Scripts>conda list | findstr xgboost

    and the xgboost package was not found.  I then ran ran

    conda install -c anaconda py-xgboost

    and the package was installed.

    I then started MSSC to create the following python script:

    EXEC sp_execute_external_script @language = N'Python',
    @script = N'
    
    import xgboost
    
    print("done.")
    ';
    
    GO

    When I executed the script I got:

    Msg 39004, Level 16, State 20, Line 0
    A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
    Msg 39019, Level 16, State 2, Line 0
    An external script error occurred: 
    
    Error in execution.  Check the output for more information.
    Traceback (most recent call last):
      File "<string>", line 5, in <module>
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\MSSQL\ExtensibilityData\HEDGETOOLS01\5AE42737-FB6F-4B35-9675-63E252C9E219\sqlindb.py", line 31, in transform
        import xgboost
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\site-packages\xgboost\__init__.py", line 11, in <module>
        from .core import DMatrix, Booster
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\site-packages\xgboost\core.py", line 115, in <module>
        _LIB = _load_lib()
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\site-packages\xgboost\core.py", line 109, in _load_lib
        lib = ctypes.cdll.LoadLibrary(lib_path[0])
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\ctypes\__init__.py", line 429, in LoadLibrary
        return self._dlltype(name)
    
    Msg 39019, Level 16, State 2, Line 0
    An external script error occurred: 
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\ctypes\__init__.py", line 351, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] The specified module could not be found
    
    SqlSatelliteCall error: Error in execution.  Check the output for more information.
    STDOUT message(s) from external script: 
    SqlSatelliteCall function failed. Please see the console output for more information.
    Traceback (most recent call last):
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 406, in rx_sql_satellite_call
        rx_native_call("SqlSatelliteCall", params)
      File "S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\lib\site-packages\revoscalepy\RxSerializable.py", line 291, in rx_native_call
        ret = px_call(functionname, params)
    RuntimeError: revoscalepy function failed.
    
    

    I don't have any python environments but my original installation of python set environment variables the point to my original installation:

    PYTHONPATH C:\Users\Charles\Anaconda

    I also ran:

    S:\SQL_Server_2017\MSSQL14.HEDGETOOLS\PYTHON_SERVICES\Scripts>conda update --all

    and this updated almost 100 packages.  The python in SQL Server 2017 was apparently quite out of date.

    I worry that revoscalepy is confused by having two Anaconda pythons on my development machine.  How can I solve this problem.

    Charles


    Charles Brauer

    Friday, April 5, 2019 7:08 PM

All replies

  • Charles,

    Probably not the answer you want but it may be wisest to uninstall both, then start over.   SQL Server Python appears to be version specific.  Have you tried the Visual Studio Code (it's free and file based rather than application based like Visual Studio)?   VSCode has the ability to run clean with a Python extension and an mssql extension.   https://marketplace.visualstudio.com/items?itemName=ms-python.python

    I'm interested in your progress.  I'm having a similar problem here.   In the past, when I have had versioning issues with Microsoft tools, the solution has been to reinstall the prior over the top of what is installed from Microsoft.   With the open source, that may not be the right answer, but in this case, the alternative is to install Anaconda over the top of MSSQL 2017 Python.


    JRL

    Saturday, June 15, 2019 9:26 AM