Issue
I'm trying to set up a script with SQL connection, and am running into the following error:
ModuleNotFoundError: No module named 'pyodbc'
from the line:
import pyodbc
I'm using Python 3.9.2, Spyder version 4.2.3. Updated to latest Spyder version 5.0.1, no change.
Weirdly I have no trouble importing the module from the command line, it's only when I run it through Spyder that I get this issue.
Normally, from what I've read this would be a case of multiple environments, but I have yet to set up any environments so I only have one python installation.
I also have the site-packages
folder properly added to path, heck I've moved the pyodbc
files into their own directory and added THAT to the path.
I've copy and pasted the files into Spyder's packages directory too, but still didn't fix the issue.
The only thing I can think of is this:
which indicates that Spyder is using Python 3.7.9 as its interpreter rather than the version I actually have installed?
Any idea what the issue could be?
Solution
Thank you Ewran for your help.
When I changed the interpreter it gave me an error message to update my spyder-kernels which seems to have fixed the issue.
To summarize for others:
1). Make sure you have a path to C:\Users<User>\AppData\Local\Programs\Python\Python39\Lib\site-packages
2). Make sure you're installing the module to the correct environment
3). Make sure Spyder is using the correct interpreter, point it to the desired python.exe and update Spyder's kernels if needed.
Answered By - Scott
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.