Running VS Code in Windows and Python 3.9x
I created a new project folder and created a new virtual environment for this project. The first script I created is a .ipynb file (jupyter notebook), and it works fine. When I exported the script to .py file, it generates an error on first line of code:
from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'
The pynput library is installed in this virtual env, which is why the .ipynb file runs fine. When I look at the lower right corner of VS Code, I can see the virtual env is activated:
And the terminal prompt is prepended with (proj_env)
. And when I run pip list
, I can see the pynput package is installed. It is NOT installed in the system environment, which is why I'm guessing the script is trying to use system env, but I could be wrong.
What am I missing?
From the testing described in the comments, perhaps it has to do with a difference between how a Windows CMD window (running a vritual env) checks certain paths for packages the script wants to import vs how VS Code checks certain paths?