Search code examples
visual-studio-2017anacondasql-server-2017-express

Use common python libraries for SQL Server 2017 and Visual Studio 2017


The Anaconda python packages installed for Visual Studio 2017 and SQL Server 2017 are separate. Is there any way that the two programs can reference one common set of Anaconda python packages?


Solution

  • I haven't looked at this problem for that long but it appears that the options around manipulating Python environments in Visual Studio are both more numerous and more well established. So with an aim of minimising the number of anaconda versions installed on a machine, I chose to point Visual Studio Python references to the SQL Server anaconda package and delete the Visual Studio anaconda package. The below is the methodology I employed:

    1. In the Python Environments window in Visual Studio 2017 I created a custom environment and filled out the following:

      • Prefix path: C:\Program Files\Microsoft SQL Server\MSSQL14.SQLSERVER2017\PYTHON_SERVICES
      • Interpreter path: C:\Program Files\Microsoft SQL Server\MSSQL14.SQLSERVER2017\PYTHON_SERVICES\python.exe
      • Windowed interpreter: C:\Program Files\Microsoft SQL Server\MSSQL14.SQLSERVER2017\PYTHON_SERVICES\pythonw.exe
      • Language version (at the SQL Server location above) determined from here and here
      • Architecture determined from here and here
    2. Deleted the auto detected Python Environment that came with the Visual Studio 2017 installation by doing the following:

      • Navigating to the location of the anaconda package (eg C:\Program Files\Microsoft Visual Studio\Shared\Anaconda3_64), then locating and running the Uninstall-Anaconda3 executable.
      • Once the executable above is complete, delete the now invalid Visual Studio Python environment using this approach. Be sure to read the last bullet point of the "Fix or Delete Invalid Environments" section