HiveBrain v1.2.0
Get Started
← Back to all entries
patternpythonMinor

SQL Server 2017 & External Python Modules

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
modulessqlpythonserverexternal2017

Problem

I'm doing some PoC work with Python integration in SQL Server 2017.

I have got the basic steps working, & have completed this example successfully:
https://learn.microsoft.com/en-us/sql/advanced-analytics/tutorials/run-python-using-t-sql

For the PoC I'm trying to complete, I need to us some external python modules (for example tensorflow) that don't seem to come with the standard python libraries that are bundled with SQL Server.

In a standard python IDE, I would just do install with pip or git clone. If I do this on the server that is running SQL Server it completes successfully, but I can't seem to use the external modules from TSQL.

Error message is:

ImportError: No module named 'tensorflow'


Does anyone know if it is possible to do this?

I've tried googling, but not much coming back. I guess as this is such a new feature that there isn't a huge amount of knowledge in the community.

Solution

Just in case someone finds this question when searching the net

I logged an advisory case with MS as I needed an answer on this. They have come back to me with the following method that works:

Open a command prompt (as administrator) and navigate to the python directory (and inside the scripts directory)

cd c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\Scripts\Python

pip install 


Nb: There is a cleaner way to do this with R packages, but this functionality is not there for python yet. I would assume in later versions that a similar process will be available for python: https://learn.microsoft.com/en-us/sql/advanced-analytics/r/install-additional-r-packages-on-sql-server

Code Snippets

cd c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\Scripts\Python

pip install <packagename>

Context

StackExchange Database Administrators Q#188907, answer score: 4

Revisions (0)

No revisions yet.