Python in Windows – Latest Installation and Usage Commands

Python is a popular programming language used for web development, automation, data analysis, scripting, and many other tasks. You can easily install Python on Windows using Command Prompt and the Windows Package Manager. It is also beginner-friendly and can be used for many different programming projects.

Here’s what you can do with Python on Windows:

  • Write and run Python programs.
  • Create automation scripts.
  • Work with files and folders.
  • Install Python packages.
  • Build web applications.
  • Work with data and APIs.
  • Learn programming from the command line.

Install Python on Windows

You can easily install Python on Windows using a single Winget command. Open Command Prompt and run the command below to start the Python installation.

Install Python using Winget.

winget install Python.Python.3.12

Follow the instructions shown in Command Prompt to complete the installation. After installing Python, close Command Prompt and open it again. Now you can start using Python commands.

Check the installed Python version.

python --version

You can also use:

py --version

If Python is installed correctly, Command Prompt will display the installed version.

Check the Python installation path.

where python

Check the Python launcher.

where py

Python Usage Commands

You can use Command Prompt to run Python programs, check the Python version, install packages, and create virtual environments. Here are some useful Python commands to get started.

You can start the Python interactive interpreter.

python

You will see the Python prompt:

>>>

You can now run Python commands directly.

Print a message.

print("Hello World")

Perform a simple calculation.

10 + 20

Check the Python version from inside the interpreter.

import sys<br>print(sys.version)<br>

Exit the Python interpreter.

exit()

You can also run a Python file from Command Prompt.

Create a file named:

hello.py

Add the following code to the file:

print("Hello from Python")

Open Command Prompt in the folder where the file is saved and run:

python hello.py

Python will execute the program and display the output in Command Prompt.

You can use the py command to run the same file:

py hello.py

Check the installed Python packages.

python -m pip list

Check the pip version.

python -m pip --version

Install a Python package.

python -m pip install package-name

For example:

python -m pip install requests

Upgrade a package.

python -m pip install --upgrade package-name

Remove a package.

python -m pip uninstall package-name

Create a new Python virtual environment.

python -m venv myenv

Activate the virtual environment.

myenv\Scripts\activate

After activation, you can install packages inside the virtual environment without affecting the main Python installation.

To leave the virtual environment, run:

deactivate

Upgrade pip.

python -m pip install --upgrade pip

Run a Python module from Command Prompt.

python -m module_name

Show Python help.

python --help

You can also open the Python interpreter using the Python launcher:

py

Run a specific Python version if multiple versions are installed:

py -3.12

You can use these commands to run Python, manage packages, create virtual environments, and run your own Python files directly from Command Prompt.

See also  NPM in Linux – Basic Commands & Usage Guide

End Note

Python is a simple and powerful programming language for Windows. You can use it from Command Prompt to write programs, run scripts, install packages, and learn Python step by step.

SHARE THIS POST:

Leave a Reply

Your email address will not be published. Required fields are marked *