By: Rajendra Gupta | Updated: 2024-02-28 | Comments (1) | Related: > Python
Problem
What is Python programming? Is it a popular programming language? How does a programmer you install Python on Windows along with integrated development environments?
Solution
Python is a high-level or general-purpose programming language widely adopted for web development, Data Science, Machine Learning (ML) and Artificial Intelligence (AI). Python is an easy-to-understand, scalable, open-source language that allows developers to write a program with a small amount of code. It is also highly productive since it has modules and libraries for specific implementations.
Highlights of Python include:
- Easy to learn
- Useful in web applications
- Used in Machine Learning
- Used in GUI
- Built-in mathematical functions
According to the IEEE Spectrum report, Python is the number one programming language in the general "Spectrum" ranking for 2023.
In this data science series, you can learn Python concepts, fundamentals and terminology with a deep dive into the advanced topics as we move through the software development tips.
Installing Python
Python is available on Windows, Linux/Unix, macOS, and docker containers. This tip explores the installation on the Windows operating system.
Step 1 Choose the Python Version
Python 3.12.2 is the latest version. You can download it or any active Python release from the Python website.
Unless you require a specific release, click Download Python 3.12.2, which downloads the python-3.12.2-amd64.exe.
Step 2: Launch Install Wizard
Launch the setup and put ticks in the checkboxes highlighted below. It installs the PIP package manager, IDLE (Python editor), and additional documents with the file associations by default.
We can install Python directly with default options or click on Customize installation to choose the features and location.
In the Optional Features, make sure you check all features. Click Next.
On the Advanced Options window, choose the following options:
- Install Python 3.12 for all users
- Associate files with Python
- Add Python to environment variables
You can also customize the install location. If we install Python for all users, its default location is C:\Program Files\Python.
Click Install. It will quickly finish the Python 3.12.2 installation, displaying the image below.
Step 3: Verify Installation
Use Command Prompt.
To verify the installation, launch the command prompt and run the following command:
python --version
The command should return the installed Python version (below).
If you get the error that says Python is not a recognized program, add the Python path into the environment variable.
To add a Python directory to the PATH environment variable, type Edit the System environment variable in the start menu.
In the Advanced tab, locate and click on Environment Variables.
Double-click on the PATH and add the Python directory as C:\Program Files\Python312
Click OK and save the environment variable changes.
Relaunch the command prompt and run it to check the Python version; it should be successful.
Launch the Python Interpreter IDLE.
Another way to check the Python installation is to launch the Python interpreter IDLE. To do so, type IDLE in the start menu.
It launches the Python interpreter, which shows the Python version and a few keywords, such as "help", "copyright", or "license()" for more information.
You can try running the sample code to print a string "Hello, world!" in the IDLE, as shown below.
Python Integrated Development Environment (IDE)
Python IDLE or Command-line interpreter is unsuitable for large projects or programs. You can use integrated development environments such as Visual Studio Code, PyCharm, Atom, and Jupyter Notebook. You can also use the Anaconda Python distribution, a bundled package with Python and Jupyter Notebook, and install commonly used packages and package managers.
Let's explore two popular tools: Jupyter Notebooks and Visual Studio Code (VS Code). You can use any IDE you like.
Jupyter Notebook Installation
The Jupyter Notebook is a flexible and user-friendly tool for Python. Browse the Jupyter website and click on the Jupyter Notebook -> Install the Notebook.
It gives instructions for installing the JupyterLab and notebook.
However, before installing the Jupyter Notebook, we need pip (package management system) to install the packages in Python. If you do not have pip installed, it gives the following error. However, we already installed it using the custom installation.
To verify the pip package, run the command pip --version, which will give the output below.
Run the command below to install Jupyterlab:
pip install jupyterlab
Install the Jupyter Notebook with the below command.
pip install notebook
Launch the Jupyter Notebook with the command below.
Jupyter notebook
It opens the Jupyter URL. Click on New-> Notebook to launch a new Jupyter Notebook, as shown below.
You can write the code in the highlighted line. For example, let's write a sample Python code to greet the user.
def greet(): name = input("What's your name? ") print("Hello, " + name + "! Nice to meet you.") greet()
As shown below, we have executed the Python script in this Jupyter notebook.
Visual Studio Code Python IDE
VS Code is another popular integrated development editor (IDE) that supports multiple languages like SQL, PowerShell, and Python. It is Microsoft's IDE for Windows, Linux, and macOS, and it features intelligent code completion, code refactoring, source control, and debugging.
Download it from the VS Code website and follow the installation wizard to complete its installation.
You need to install the Python Extension to use Python in VS Code. Click Extensions from the left-hand vertical menu bar and search for Python.
Click Install in the Python installation.
After the package installation, it shows the option to disable, uninstall, or switch to the pre-release version.
Relaunch VS Code. Using the Get Started with Python Development option, you can walk through Python development with VS Code.
Otherwise, click New File from the Start links on the left side of the interface. It asks you to select the language for the new file.
Click Select a language and choose Python.
As shown below, write and execute the script in the VS Code Python IDE.
Next Steps
- Stay tuned for more Python tutorials in the upcoming software engineering tips.
- Explore existing
Python
tips on MSSQLTips.
- Recursion Programming Techniques using Python
- Create a Python Django Website with a SQL Server Database
- Create Your First REST API using Python, Flask and HTML Code
- Getting Started with Python Pandas and Dataset Profiling
- Python Basic Built-in Data Types
- Introduction to Creating Interactive Data Visualizations with Python matplotlib in VS Code
- Creating a Python Graphical User Interface Application with Tkinter
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2024-02-28