How to use Python virtual environment in VS Code

If you have created a python virtual environment and wish to use it to run your code in Visual Studio Code, follow these steps:

  • Open VS Code and click on the Python Interpreter at the bottom. Alternatively, you can click Ctrl+Shift+P and Select ‘Python: Select Interpreter’.
Select Interpreter
  • Click on ‘Enter interpreter path’, and then click on ‘Find’
Selecting interpreter path
  • Browse to the directory of your virtual environment, go to the Scripts folder, and select python.exe.
Selecting the .exe file
  • Click on ‘Select Interpreter’. You should now see the virtual environment as the interpreter at the bottom.

That’s it. I hope this article helped.


Check out other articles on python on iotespresso.com. If you are interested in data science, visualization, and machine learning using Python, you may find this course by Jose Portilla on Udemy to be very helpful. It has been the foundation course in Python for me and several of my colleagues.

Leave a comment

Your email address will not be published.