How To Install Python And Configure It With Visual Studio Code Editor With Git Bash

Introduction

 
In this article, let's learn the basics of Python along with its advantages and step by step installation, with examples. 
 
Let's start.
 

What is Python?

 
Python is an interpreted high-level programming language. It is used for general purpose programming. It is open source and by using it, we can create Console applications, Windows applications, as well as Web applications. It supports interactive layouts, objective-oriented approach, procedural and functional programming, automatic memory management. Even after having these much capabilities, Python is easily readable and very easy to learn and understand.
 
It encourages software developers or data analysts to rapidly develop very attractive applications.
 

Uses of Python

 
Python is used for Machine Learning, Data Analysis, Deep Learning, Artificial Intelligence, and Console, Desktop and Web Applications. Some of the renowned companies using Python include -
  • Google
  • Cisco
  • Mozilla
  • Instagram
  • YouTube
  • New York Stock Exchange (NYSE) etc.

Features of Python

  • Easy to read and understand
    Python is very easy to understand for freshers and experienced people.
     
  • Easy to maintain
    Python is very easy to maintain because of the clarity in writing the code.
     
  • Large library 
    Python has a huge collection of libraries for easy programming, which makes it very popular in the world.
     
  • Case Sensitive
    Python is case-sensitive just like the C language.
     
  • Cross-Platform
    After writing a single code, you can run it on various OSes.

Data Science and Machine Learning with Python

 
Data Analysis has become very popular recently with the support of Python. Python has n numbers of libraries which are used for data science or machine learning and deep learning using Python interfaces.
 
Indentation
 
As we know, in C and C++, we use curly brackets for separating each scope or conditional statement. In Python, we use white-space for indentation rather than curly brackets or keywords.
 

How to install Python?

 
There are several ways of installing Python, as given below.
  1. Installing Python using Anaconda, Jupyter Notebook, and Spyder.
  2. Installing Python by directly downloading from the official website and using it with VS Code Editor.
In here, we will install Python directly by downloading from the official website. Then, we will be using VS Code Editor to create a program. Let's follow the step-by-step procedure.
 
Step 1
 
Go to the official website of Python and download the appropriate variant as per your operating system - Windows, Linux/UNIX, or Mac OS X. I am using Windows, so I will show you all installation steps of Python for Windows.
 
After opening the official website, we will see a screen like below.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash 
 
Click on the latest version of Python for Windows, i.e., 3.7.0. The size of this executable is 24.3 KB.
 
Step 2
 
After downloading it, double-click on it or "Run as Administrator".
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash 
 
Step 3
 
Please make sure that the "Add Python 3.7 to PATH" checkbox is checked. If not, do it manually, like below.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Step 4
 
Now, click on the "Install Now" link. The progress will start. For the next few steps, keep clicking "Next" until the Python is installed on your system.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Step 5
 
Once the installation is complete, you will get a message, "Setup was successful".
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Step 6
 
After completing the installation of Python, restart your system for checking if Python is successfully installed or not. Open the command prompt.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash 
 
Step 7
 
In the above snapshot, you can see that Python 3.7.0 is installed successfully on your system. When we install Python, it installs the Python IDE by default, which is IDLE. For running the Python, open its IDLE IDE.
 
Go to Windows Search=> IDLE and double-click on this.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Python Shell will open.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Now, click on the File menu. A "New File" dialog will open.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Now, I want to print a simple message. So, let's write a print command for displaying the message. Go inside the file, and type the following command.
 
print ("Welcome Python")
 
Now save this file anywhere you want with any name and the .py extension. After saving this, to show the output, click on Run and select "Run Module" or press F5 to run this file.
 
Output
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Python is supported by many IDEs, as given below.
  1. VS Code
  2. IDLE
  3. Eclipse
  4. PyCharm
  5. Sublime
  6. Spyder
  7. Wing IDE
  8. PyScripter
  9. PyDev
  10. Jupiter Notebook etc.

Configure Visual Studio Code Editor with Gitbash for Python

 
Go to the official website of Gitbash and download it.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash 
 
After download, run it and click on the "Next" button. 
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Click "Next".
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Click "Next".
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
Again, click the "Next" button. This message shows that Gitbash is successfully installed.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash
 
After successful installation of Gitbash, let us download the VS Code Editor and install it.
 
Once done, open VS Code Editor and go to File->Preferences->Extension. Or, simply press Ctrl+Shift+X. A new extension box will open. Type Python here.
 
How To Install Python And Configure It With Visual Studio Code Editor With Git Bash 
 
Now, click on Install. After installing Python, now reload it. For configuring Gitbash with VS Code Editor, got to -
 
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
 
Now, go to File->Preferences->Settings.
 
Click on the top-right pane and click on "Show modified settings". Inside it, paste the above URL. Now finally, your Python, Gitbash, and VS Code are installed successfully on our computer system. Just restart your VS Code Editor. 
 
I hope this will help you.


Similar Articles