nilsinelabore
nilsinelabore

Reputation: 5095

Import pyodbc in Visual Studio Code

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?

Upvotes: 0

Views: 21217

Answers (3)

Kür Şad
Kür Şad

Reputation: 1

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.

Upvotes: 0

Zeailer
Zeailer

Reputation: 66

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

Upvotes: 0

nilsinelabore
nilsinelabore

Reputation: 5095

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.

Upvotes: 1

Related Questions