Published on: 26 Oct, 2021

Updated on: 02 Dec, 2021

How To Setup Our Own Python Interpreter In Pycharm & VS Code

Here we will be discussing regarding setting up the Python environment in IDE and text editor

When there is a question of productivity and efficiency while programming, one always go for one of the Integrated Development Environment (IDE) or Text editors. Now, the most challenging part is to set up our own development environment within IDE or Text editors. So, in this article, we will be exploring how to set up a Python environment within IDE & Text editor.

There are various IDEs and Text editors available in the market for various programming languages. To know more about some of the most popular and commonly used IDEs & Text editors among developers community, please refer our post

Let's explore the most popular & commonly used IDEs & Text editors for coding

Here, we are not going to cover all of them but I would like to focus mostly two of them which are having great demand when it comes to Python development.

  1. Pycharm (IDE)

  2. VS Code (Text Editor)

Setting up a Python environment in Pycharm IDE

Before starting make sure you have Python installed on your system. If not, please refer our article to set up Python at: Python installation & setup on Windows/Mac/Linux

Secondly, you have to make sure the Pycharm Community version is installed on your system. If not, please refer our article on how to download Pycharm at: Let's explore how to set up Pycharm on Mac/Windows/Linux

  1. Launch Pycharm application and create a new project by clicking on +Create new project Create new project
  2. Set the project name and click on the arrow button > to expand the virtual environment setting. Create new project
  3. If you notice, you can see it is picking by default the system python version and creating a virtual environment for our project Create new venv
  4. Click on the OK button and wait for a while till the time the project set up is done.
  5. On the left panel of the project explorer window, you can find the name of our project - MyNewProject newprojectleftpanel
  6. Now to set the new python environment for this project, go to Preferences preferences
  7. Select Python Interpreter under Python: MyNewProject
  8. On the right panel, you will see a new window with the current Python environment of 2.7 defaultenv
  9. Click on the up-down arrow button and click Show All

  10. A new window will open and you will find all the Python environment that you would have created on your system or may be installed on your system. selectvenvfromoptions

  11. If you do not find any other Python environment than default one then click on + icon at the bottom left
  12. A new dialog box will open, just click on the Existing environment and click on box with dot ... existingenv
  13. Now select the folder of your virtual environment from your local system and navigate to the python3 file within bin folder and click the OK button selectvenv
  14. Select the recently added Python environment from options and click OK selectenv
  15. Click on Apply and then OK button clickapply
  16. Now go to project explorer panel on left and expand External Libraries and you will see our new Python version that we just set newpythoninterpreter

Setting up a Python environment in VS Code

Before starting make sure you have VS Code installed on your system. If not, please refer our article to set up Python at: Text Editors installation & setup on Windows/Mac/Linux

  1. Launch VS Code application and open your Python project in it
  2. Click four square on the left panel of VS Code and install Python plugin foursquare searchpython
  3. Press Ctrl+Shift+P (for windows) & Cmd+Shift+P (for mac) and type Python Interpreter and click on Select Interpreter pythoninterpreter
  4. From the list of Python Interpreter options, select one of the them based on your project selectvenvfromoptions
  5. After slecting one of the interpreter, you will find a new folder with name .vscode get created on left panel
  6. Open the settings.json file from .vscode folder and you will find the recently selected Python interpreter settingfile
  7. From next time onwards, for the same project if you want to change Python interpreter simply change the path in settings.json file
  8. If everything went well then you should see recently selected Python interpreter at the bottom left corner of VS Code afterpythonselect

Share with your love's one!