In our python file inside VSCode
editor, the import pyodbc
declaration gives the following error:
Import "pyodbc" could not be resolved from sourcePylancereportMissingModuleSource
However when I try to install pyobdc
, I get the following message:
PS C:\PyCopilotProject\my-python-project> pip install pyodbc
Requirement already satisfied: pyodbc in c:\users\myusename\appdata\local\programs\python\python310\lib\site-packages (4.0.32)
And the following code verifies that the package pyodbc (4.0.32)
is indeed installed.
PS C:\PyCopilotProject\my-python-project> pip list
Question: What could be a cause of the error and how we can resolve it?
It depends on what interpreter you're running import pyodbc.
python -m venv path\to\venv
Ensure your virtual environment is activated:
path\to\venv\Scripts\activate
and install pyodbc in the active virtual environment
pip install pyodbc