Reputation: 43
Im new to using python, and having some trouble using pyodbc to connect to MS SQL. I've reinstalled almost everything except windows so far. reinstalled a few times, both with pip/pip3. Even tried older versions of pyodbc. Only have one version of python installed. Not running any VM.
using python 3.8-32, with pyodbc 4.0.32. Error im getting is:
"pyodbc" is not accessed Pylance
Import "pyodbc" could not be resolved Pylance (reportMissingImports)
Just to mention it, have been searching for a fix for this for a few hours now, getting a bit weary. cant find a fix or even anything postet within 2 years that is relatable.
Anyone got any tips/suggestion would be much appreaciated by a PythonNewbie.
Upvotes: 4
Views: 34459
Reputation: 1121744
The error you show is one given by your editor, not by Python. Pylance is an extension for Visual Studio Code (VSCode) to help the editor understand Python code. It simply means that Pylance is not using the same Python binary as your project.
Open the command palette and type "Python: select interpreter", then find your Python interpreter that has pyodbc installed. See the documentation on using Python environments.
Note that even with as single Python installation, you can have multiple virtual environments. You may have installed PyODBC in a virtual environment, or in the system Python packages, but if Pylance is looking at the wrong environment it won't find PyODBC.
Upvotes: 8