I had the same type of issue with the pandas module on SQL Server 2017 with the same ImportError message that you received. The issue surfaced after installing CU22 for SQL Server 2017 recently and was not present when I set up the environment in question about two months earlier.
In my setup of the environment I performed an upgrade of the numpy and pandas modules to the latest available versions for Python 3.5.2 (which is the default Python version included with SQL Server 2017):
- numpy:
- Pre-installed version: 1.12.1
- Updated version: 1.18.5
- pandas:
- Pre-installed version: 0.19.2
- Updated version: 0.24.2
The reason for the upgrades were requirements from other modules (on numpy) and compatiblity issues between pandas and the new numpy version.
After receiving the ImportError error message when doing import pandas, I pinpointed it to line 9-10 in the file:
C:\Program Files\Microsoft SQL Server\MSSQL14.<instance_name>\PYTHON_SERVICES\Lib\site-packages\pandas\core\dtypes
from pandas.compat import (
PY2, Set, re_type, string_and_binary_types, string_types, text_type)
As I could not find any reason nor any reference from Microsoft on why this should stop working, I did some research and found this post from the pandas Github project:
Missing required dependencies ['numpy'] on pandas 0.24.1 #25316
It seems that there can be issues with old, installed versions of the numpy and pandas modules, even though they are supposed to be removed by pip.exe during the module upgrade/installation process.
Fair enough, I ran repeated uninstalls of the pandas and numpy modules until pip.exe no longer reported any installed versions and the related directories were gone from Lib\site-packages
Set-Location 'C:\Program Files\Microsoft SQL Server\MSSQL14.instance_name\PYTHON_SERVICES\Scripts'
& '.\pip.exe' uninstall pandas # repeated 2 times
& '.\pip.exe' uninstall numpy # repeated 2 times
In both cases, both the updated and some remaining parts of the original versions of the modules were removed.
I then reinstalled both modules and had no issues after that:
& '.\pip.exe' install --upgrade numpy
& '.\pip.exe' install --upgrade pandas
Best Answer
These are actually very poor instructions on how to remove the Microsoft SQL Server.
SQL Server installs these associated packages.
Assuming you wish to totally remove SQL Server, you should