Import pyodbc in Visual Studio Code

Question:

I would like to access SQL Data from Visual Studio Code, following this tutorial Access Azure SQL Database from Visual Studio Code using Python it caught an error when I tried to import pyodbc with

import pyodbc

the error:

ModuleNotFoundError                       Traceback (most recent call last)
 in 
----> 1 import pyodbc

ModuleNotFoundError: No module named 'pyodbc'

I then followed this tutorial: Step 1: Configure development environment for pyodbc Python development to install pyodbc. I installed the Microsoft ODBC Driver for SQL Server on Windows but the error remained. What is wrong? Is there an alternative way to access SQL data from Visual Studio Code?

Asked By: nilsinelabore

||

Answers:

Realised it was a bit of a silly question, but just in case someone else has the same issue, using

pip install pyodbc

in the VS Code terminal will solve the problem.

Answered By: nilsinelabore

If anybody still needs some help my problem was installing python through the Microsoft store.

The fix was to uninstall python and install it using official website

after that just follow the guide you already provided

Answered By: Zeailer

I do project that needs pyodbc, and I take that error too.
My python interpreter version was "Python 3.11.2 64-bit", I switched it to "Python 3.10.10 64-bit (microsoft store)" version. Then it worked!

With Python 3.11.2 64-bit.

With Python 3.10.10 64-bit (microsoft store). Note: Not ‘eror’, error.

Answered By: Kür Şad