I can't get Code Runner extension to work with virtualenvs. Whenever I try to run code that imports a library that is installed only in the virtualenv and not in the global Python installation I get an import error. Running the exact same code in terminal works.
I am on Windows 10 and I have Python 3.6.5 installed.
The precise error I am getting is:
ModuleNotFoundError: No module named 'bs4'
I also faced same issue.
solution which i found best is just add this line to your user or workspace settings(whichever is suits your projects):
"code-runner.executorMap": {
"python": "C:\\Users\\adarsh_patel\\VisualCode\\env\\Scripts\\activate.bat && python -u",
}
you have to enter your virtualenv path or you could use.
"code-runner.executorMap": {"python":"$pythonPath $fullFileName"}
hope this helps you.