dbt-sqlserver, Python 3.11, old pyodbc version

Trying to install the dbt-sqlserver package via pip (Python 3.11) results in an error related to pyodbc.

The error is: “Microsoft Visual C++ 14.0 or greater is required.”

Microsoft Visual C++ is installed on the local machine, and in the right version.

Installing pyodbc on its own goes just fine. However, the version of pyodbc that dbt-sqlserveris trying to install is 4.0.32 whereas the most recent version currently available is 4.0.35.

I asked pyodbc maintainers for help and they said that version 4.0.32 didn’t have wheels for Python 3.11: Windows 11. Python 3.10.1 Impossible to install pyodbc · Issue #1010 · mkleehammer/pyodbc · GitHub

I am just starting my Python adventure and I don’t really understand what is going on here. Pyodbc maintainers are suggesting reaching out to dbt-sqlserver authors and clarify with them why they are including an older version of pyodbc library in their product.

This is the exact error message I am getting:

      running build
      running build_ext
      building 'pyodbc' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Rolling back uninstall of pyodbc
  Moving to c:\program files\python311\lib\site-packages\pyodbc-4.0.35.dist-info\
   from C:\Program Files\Python311\Lib\site-packages\~yodbc-4.0.35.dist-info
  Moving to c:\program files\python311\lib\site-packages\pyodbc.cp311-win_amd64.pyd

It is a Windows 11 PC with Python 3.11.0

Any hints welcome.

Hey @xpil, dbt Core only supports Python 3.11 from v1.4, which is currently in release candidate status.

Once it goes GA, the dbt-sqlserver package can also add 3.11 support. I imagine that part of that process will include reviewing the pyodbc version it depends on.

In the meantime, are you able to try installing dbt on Python 3.10? I don’t use Windows so can’t give hyper-specific guidance, but I have skimmed this article and think that it does a good job of showing how to get multiple python environments set up. When you create a python virtual environment for 3.10 you can install dbt into that. (It’s a good idea to put dbt into a venv regardless, to protect it from other weird things happening as you install other Python libraries and vice versa.)

PS: thanks for the great writeup of your issue! Really helpful :pray:

I’ve also run into a similar issue while trying to create an image, although using Ubuntu 20.04 and tried Python v 3.7, 3.8, 3.9 & 3.10

For info, turned out to be a driver issue for me.
The following line in my Dockrfile solved the issue:

RUN apt-get install unixodbc-dev -y

1 Like