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'
You can check and disable compatibility mode by right-clicking on the VS Code executable and selecting properties, then uncheck the Run this program in compatibility mode option in the compatibility tab.
To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With