The full process of installing and setting Python on your computer

онлайн тренажер по питону
Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

A self-study guide for Python 3 compiled from the materials on this site. Primarily intended for those who want to learn the Python programming language from scratch.

Introduction

Python is a high-level general-purpose programming language that has become one of the most in-demand in the world since its inception in the late 1980s. According to the Stack Overflow Developer Survey 2023, Python ranks third in popularity among developers. Its ease of learning, code readability, and rich ecosystem of libraries make it an ideal choice for both beginners and experienced programmers.

What is Python and its main advantages

History and philosophy of language

Python was created by Guido van Rossum in 1989 with the aim of creating a language that would be both powerful and easy to learn. The name comes from the British comedy series Monty Python, reflecting the friendly and accessible nature of the language.

Key features of Python

Simplicity and readability: Python uses indentation to structure code, which makes it visually understandable even for beginners.

Interpreted language: The code is executed line by line, which simplifies debugging and testing.

Cross-platform: Python runs on Windows, macOS, Linux and other operating systems.

Rich standard library: Includes modules for working with files, network, databases, and more.

Huge community: An active community of developers is constantly creating new libraries and tools.

Python Application areas

Web development: Django, Flask, and FastAPI frameworks allow you to create powerful web applications.

Data analysis and machine learning: pandas, NumPy, scikit-learn, TensorFlow, PyTorch libraries.

Automation and scripts: Ideal for automating routine tasks.

Scientific Computing: Widely used in research and academia.

Game development: Pygame and other libraries for creating 2D games.

Desktop applications: Tkinter, PyQt, Kivy for creating GUI applications.

System requirements and preparation for installation

Minimum system requirements

Operating system: Windows 7 SP1 or higher, macOS 10.9 or higher, Linux (most distributions)

RAM: Minimum 512 MB (2 GB recommended)

Free disk space: 100 MB for basic installation

Processor: Any modern x86 or x64 processor

Checking the current Python version

Before installing, check if Python is already installed on your computer:

python --version
python3 --version

If Python is installed, you will see the version number, for example: Python 3.11.5

Detailed installation of Python on different operating systems

Installation on Windows

Method 1: Official Installer (recommended)

Step 1: Go to the official website python.org and click "Download Python" to download the latest version.

Step 2: Choose the appropriate architecture:

    64-bit version (for modern computers)
  • 32-bit version (for older systems)

Step 3: Run the downloaded installer (.exe file).

Step 4: Make sure to check the boxes in the installer window:

  • "Add Python to PATH" (critically important!)
  • "Install launcher for all users" (optional)

Step 5: Select the installation type:

  • "Install Now" - quick installation with default settings
  • "Customize installation" for advanced users

Step 6: In the advanced settings, it is recommended to note:

  • "Install for all users"
  • "Add Python to environment variables"
  • "Precompile standard library"

Step 7: Select the installation path or leave it as the default.

Step 8: Wait for the installation to complete and click "Close".

Method 2: Microsoft Store

A simplified installation is available for Windows 10/11 via the Microsoft Store:

  1. Open the Microsoft Store
  2. Find "Python" from the Python Software Foundation
  3. Click "Install"

Method 3: Chocolatey (for advanced users)

choco install python

Installation on macOS

Method 1: Official Installer

Step 1: Download the installer from python.org for macOS.

Step 2: Run the downloaded .pkg file.

Step 3: Follow the instructions of the installation wizard.

Step 4: Enter the administrator password if necessary.

Method 2: Homebrew (recommended for developers)

# Installing Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh )"

# Installing Python
brew install python

Method 3: pyenv (for version control)

# Installing pyenv
brew install pyenv

# Installing a specific version of Python
pyenv install 3.11.5
pyenv global 3.11.5

Installation on Linux

Ubuntu/Debian

# Updating the list
of sudo apt update packages

# Installing Python 3
sudo apt install python3 python3-pip python3-venv

# Checking the installation
of python3 --version
pip3 --version

CentOS/RHEL/Fedora

# For CentOS/RHEL
sudo yum install python3 python3-pip

# For Fedora
sudo dnf install python3 python3-pip

# Create symbolic link (optional)
sudo ln -s /usr/bin/python3 /usr/bin/python

Arch Linux

sudo pacman -S python python-pip

Checking the correctness of the installation

After installation, run the following commands to verify:

# Python version check
python --version
python3 --version

# Checking pip
pip --version
pip3 --version

# Simple
python -c test "print('Python has been successfully installed!')"

Configuring the development environment

Selection of IDEs and editors

PyCharm (recommended for serious development)

Advantages:

  • Intelligent auto-completion
  • Powerful debugger
  • Integrated version control system
  • Support for web frameworks

Disadvantages:

  • It may be slow on weak computers
  • Paid Professional version

Visual Studio Code (universal choice)

Advantages:

  • Easy and fast
  • A rich ecosystem of extensions
  • Free
  • Excellent Python support via extensions

Recommended extensions:

  • Python (Microsoft)
  • Pylance
  • Python Docstring Generator
  • Python Indent
  • autoDocstring

Jupyter Notebook (for data analysis)

pip install jupyter
jupyter notebook

Advantages:

  • Interactive development
  • Data visualization
  • Documenting the code
  • Popular in the scientific community

Other popular editors

Sublime Text: A fast and customizable editor with Python support.

Atom: A free editor from GitHub (support discontinued).

Spyder: An IDE specifically for scientific computing.

Thonny: A simple IDE for learning Python.

Package management using pip

Basic pip commands

# Installing
the pip package install package_name

# Installing a specific version
of pip install package_name==1.2.3

# Updating
the pip install package --upgrade package_name

# Removing
the pip package uninstall package_name

# List of installed
pip list packages

# Information about
the pip show package_name package

# Installation from requirements.txt
pip install -r requirements.txt

# Creation requirements.txt
pip freeze requirements.txt

Working with requirements.txt

File requirements.txt contains a list of project dependencies:

numpy==1.24.3
pandas==2.0.3
matplotlib>=3.7.0
requests
flask==2.3.2

Alternative Package Managers

Poetry: A modern dependency manager with improved version control.

Pipenv: Combines pip and virtualenv for simplified dependency management.

Conda: Especially popular in the scientific community for package and environment management.

Virtual Environments: a complete guide

Why do we need virtual environments?

Project isolation: Each project can have its own library versions.

Conflict Prevention: Avoiding compatibility issues between projects.

Reproducibility: Easily recreating the environment on another computer.

System cleanliness: Do not pollute the global Python environment.

Creating and managing venv

# Creating a virtual
python environment -m venv myproject_env

# Activation
# Windows:
myproject_env\Scripts\activate
# macOS/Linux:
source myproject_env/bin/activate

# Deactivate
deactivate

# Removing
the rm -rf myproject_env environment # Linux/macOS
rmdir /s myproject_env # Windows

Working with virtualenv

# Installing virtualenv
pip install virtualenv

# Creating an environment
virtualenv myproject

# Activation is the same as that of venv

Conda environments

# Creating an environment
conda create -n myproject python=3.11

#
Conda activate myproject activation

# Deactivate
conda deactivate

#
Conda env list of environments

# Removing
the conda env environment remove -n myproject

Online Python programming platforms

Repeat: the perfect choice for beginners

Features:

  • Free plan with restrictions
  • Real-time collaboration
  • Multi-language support
  • Built-in database
  • The possibility of deploying applications

Advantages:

  • Does not require installation
  • Simple interface
  • Good documentation
  • An active community

Google Colab: the power of cloud computing

Features:

  • Free access to GPU and TPU
  • Pre-installed libraries for ML
  • Integration with Google Drive
  • Jupyter Notebook Support

Ideal for:

  • Machine learning
  • Data analysis
  • Scientific research
  • Training

Jupyter Notebook Online

Available services:

  • MyBinder.org
  • Jupyter.org/try
  • CoCalc
  • Azure Notebooks

Other online platforms

CodePen: For web development with Python (via Skulpt).

Trinket: A simple online learning editor.

Programiz: An online compiler with code examples.

OneCompiler: A fast online compiler.

Online vs on-site development comparison

Criterion Online Locally
Ease of getting started ⭐⭐⭐⭐⭐ ⭐⭐⭐
Performance ⭐⭐⭐ ⭐⭐⭐⭐⭐
Setting up the environment ⭐⭐ ⭐⭐⭐⭐⭐
Work without Internet ⭐⭐⭐⭐⭐
Collaboration ⭐⭐⭐⭐⭐ ⭐⭐⭐
Cost ⭐⭐⭐⭐ ⭐⭐⭐⭐⭐

The first steps: writing and running Python code

Creating the first program

# hello_world.py
print("Hello world!")
print("Welcome to Python!")

# Simple calculations
a = 10
b = 5
print(f"The sum of {a} and {b} is {a + b}")

Launching the program

# From
the python command line hello_world.py

# Interactive
python mode
>>> print("Greetings from interactive mode!")
>>> exit()

Useful commands for beginners

# Getting
python -h help

# Checking the path to Python
python -c "import sys; print(sys.executable)"

# List
of python -c modules "help('modules')"

# Information about the
python -c system "import sys; print(sys.version_info)"

Solving typical installation problems

Windows

Problem: "Python is not recognized as an internal or external command" Solution: Add Python to the PATH via "Environment Variables"

Problem: Error when installing packages Solution: Run the command prompt as an administrator

macOS

Problem: Conflict between system Python and installed Solution: Use python3 instead of python

Problem: Errors when installing packages with C extensions Solution: Install Xcode Command Line Tools

Linux

Problem: No pip Solution: Install python3-pip via the package manager

Problem: Access rights when installing packages Solution: Use virtual environments or the --user flag

Best practices for working with Python

Project structure

myproject/
├── requirements.txt
├── README.md
├── setup.py
├── myproject/
│   ├── __init__.py
│   ├── main.py
│   └── utils.py
├── tests/
│   ├── __init__.py
│   └── test_main.py
└── docs/
    └── index.md

Coding style

Follow PEP 8 - the official Python style guide:

# Good
def calculate_sum(first_number, second_number):
"""Calculates the sum of two numbers."""
return first_number + second_number

# Bad
def calcSum(x,y):
return x+y

Using linters

# Installing popular
pip install pylint black flake8 linters
# Checking
the pylint code myfile.py
flake8 myfile.py
# Automatic formatting
black myfile.py

categories

  • Introduction to Python
  • Python Programming Basics
  • Control Structures
  • Data Structures
  • Functions and Modules
  • Exception Handling
  • Working with Files and Streams
  • File System
  • Object-Oriented Programming (OOP)
  • Regular Expressions
  • Additional Topics
  • General Python Base