Pytest Installed, but VS Code Won't Access Pytest


I’m starting to learn how to write tests for my code.

I’ve installed pytest on my device using pip.

But VS Code won’t access it. I assume it’s something to do with the path. I’ve tried using different IDEs, but I can’t find one that will let me use pytest without installing it.

This is the message I get.


I’ve added a path, and I assume it’s being added in the correct place. But it still doesn’t work.


I’ve tried looking online for almost two hours now… But I don’t understand proposed solutions when others have asked similar questions, and the solutions don’t appear to help me anyway.


Many thanks in advance if anyone could help me.

Check if VS Code is using the same python interpreter, as for which pip was used.

May I ask how I do that? Thanks

From command palette ( ctrl + shift + p) type: >Python: Select interpreter

1 Like

Thanks, I’ve just tried that, switching between 3 different versions. But it hasn’t worked.

Sorry, I might have been looking at this wrong. The is not accessed error can mean that pytest is not used in the file to which it’s imported.

It’s the same whether I write a function that employs pytest or if I don’t

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.