I'm trying to 'import datefinder' in my SQL Server Python script, but for some reason it doesn't work. Other libraries (for example Pandas) seem to work just fine.
I've tried following script in Python;
import sqlmlutils
connection = sqlmlutils.ConnectionInfo(server="xxx", database="xxx")
sqlmlutils.SQLPackageManager(connection).install("datefinder")
And receive following error message;
MSSQLDatabaseException: (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (xxx\xxx)\n')
When I try to run my script in SQL Server I get following error;
Msg 39004, Level 16, State 20, Line 1 A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004. Msg 39019, Level 16, State 2, Line 1 An external script error occurred:
Error in execution. Check the output for more information. Traceback (most recent call last): File "", line 5, in File "C:\PROGRA~1\MICROS~4\MSSQL1~1.DEV\MSSQL\EXTENS~1\DEV201701\64B0BBDF-3497-42E2-8C54-38CA1EA8CD85\sqlindb.py", line 37, in transform import datefinder ImportError: No module named 'datefinder'
SqlSatelliteCall error: Error in execution. Check the output for more information.
https://thomaslarock.com/2018/05/adding-python-packages-to-sql-server-2017/
Best explanation I could ever find !
EXEC sp_execute_external_script
@language =N'Python',
@script=N'import sys; print("\n".join(sys.path))'
Lets you retrieve the path to the python environment used by SQL Server:
C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER2017\PYTHON_SERVICES\lib\site-packages\setuptools-27.2.0-py3.5.egg
Open a command line, navigate down to your PYTHON_SERVICES/Scripts
directory.
From there, call pip install datefinder
You will need to have the rights to do this.
User contributions licensed under CC BY-SA 3.0