How do I fix an error returning "import "pytest" could not be resolved Pylance?

40 Views Asked by At

I am new to coding so I'm not sure where to even start in correcting this. I've reached out to my teacher for help, but he hasn't gotten back to me and I really wanted to finish this assignment tonight so if anyone could help I would be forever grateful.

code with error

I followed the steps my teacher provided in order to install pytest on the command prompt, but when I try typing pytest --version it doesn't recognize pytest there either.

command prompt with error

I tried going to the Command Palette and selecting the Python Interpreter based on a reddit thread I found suggesting it and restarted VS Code, but it didn't seem to have any effect.

1

There are 1 best solutions below

0
MingJie-MSFT On

You could select your python interpreter in VSCode by shortcuts "Ctrl+Shift+P" and type "Python: Select Interpreter" and choose the python interpreter which you installed the package in.

If it still not work, you could run command pip install pytest in the terminal to install the package in the current interpreter.