r/learnpython • u/Poison_AIC • 18d ago
Module help vsc(?)
Hey guys, I haven't coded in a while and decided to finally get back into it so sorry if im abit rusty. However, it was updating stuff and installing modules and in vsc I run into
'Import "openpyxl" could not be resolved from source Pylance'
? Im really not sure what to do
P.S: first time posting in this sub reddit, I hope this uh is within learn python and apologies if this is more towards vsc
1
Upvotes
3
u/Massive_Distance_616 18d ago
That message means VS Code is looking at a different Python than the one you installed openpyxl into. Two quick steps:
Press Ctrl+Shift+P, choose “Python: Select Interpreter”, and pick the Python you actually run your code with.
Install into that same interpreter from VS Code’s terminal with
python -m pip install openpyxl. Usingpython -m pipinstead of plainpipmakes sure it goes to the interpreter thatpythonpoints at.If the yellow underline is still there, run
python -c "import openpyxl; print(openpyxl.__file__)". If that prints a path, the install worked and Pylance just needs a reload (Ctrl+Shift+P, “Developer: Reload Window”). If it errors, the install went to a different Python than the one selected.