'SQL Server ModuleNotFoundError: No module named 'selenium'
I'm using SQL Server 2019. I have a Python web scraping script that uses the Selenium packages - this all works fine in Visual Studio Code. I now want to run it in SQL Server via a Stored Procedure. If I try and call it via a Stored Procedure I keep receiving the message:
ModuleNotFoundError: No module named 'selenium'
If I open Azure Data Studio on the SQL Server machine, go to the Python kernal, manage packages I can see Selenium installed:
I have SQL Server machine learning services installed and if I run the below it does confirm it is not installed:
EXECUTE sp_execute_external_script
@language = N'Python',
@script = N'
import pkg_resources
pkg_name = "selenium"
try:
version = pkg_resources.get_distribution(pkg_name).version
print("Package " + pkg_name + " is version " + version)
except:
print("Package " + pkg_name + " not found")
'
So, back to SQL server - if I then go to the PYTHON_SERVICES folder and run the below:
scripts\pip.exe install selenium
I now receive the error:
import InvalidSchemeCombination, UserInstallationInvalid
How do I install Selenium on the SQL Server so I can execute the Python script via a SQL Stored Procedure?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


