Before start the Python Programming language, First, you install the python in your system. The most beginners are stuck here: some people struggle with the setting path and the some people are encounters a “ python is not recognized” error and some are unsure about which versions to download.
In this article, we will understand how to install the python step by step, How to check the Python install is correct or not and how to manage the virtual environment and multiple versions.
Some Important Points before Installing
Which version should you Install?
You should install the latest version of Python 3, as Python 2 was officially discontinued several years ago. Now there is no any updates. The new versions of Python 3 download the official website python.org/downloads.
A bit suggestion is that if you install the python for the specific library or course then first check the official documentation to which support the python version.
Where should you download
You can download and install the python only for the official website python.org. You should avoid downloading from third party websites, as they may contain malware or unwanted software.
System requirements
- Windows 10 or new versions (64 bits best)
- The recent version of macos.
- Any modern Linux distribution
- Some free spaces approx 100 mb and internet connection.
Part 2: Installing Python on Windows
Step 1: Download Installer
Open the python.org/downloads links. You will see a yellow "Download Python 3.x.x" button. Click it to download the .exe installer.
Step 2: Run the Installer
Click the download file, a windows open. There is an important points to check the checkbox. “Add python.exe to PATH” must be checked nd then click the install button.
Step 3:Wait for the Installer to Complete
Once the progress bar is complete, "Setup was successful" will appear. You can now close it. If Windows displays an option to "Disable path length limit," it is a good idea to enable it.
Step 4: Check that it has been installed correctly.
Open the command prompt and write it.
python --version
If the output show like that, then congratualtions you can install the python succesfully.
Python 3.x.x
After that, you check the pip is installed by running the following commands.
pip --version
Step 5: Run the First Program
Write the pyhron in command propt and then press the enter button. Now write this command.
print("Hello, World!")
The output should be shown the Hello, World!. You can write the exit() command to exit.
Part 3: Install it from Mac and Linux
macOS
Step 1: Official installer.
Download the macOS .pkg installer from the official python.org website. Double-click the downloaded file and follow the on-screen instructions to complete the installation. This is the easiest way to install Python on macOS.
Step 2: Homebrew.
If you use Homebrew, run the following command in the Terminal:
brew install python
Check the Status.
python3 --version
On macOS, you can use python3 instead of python to run Python commands.
Linux (Ubuntu / Debian)
Most Linux distributions come with Python pre-installed. First, you check whether Python is already installed on your system:
python3 --version
If the python is not installed then update it.
sudo apt update sudo apt install python3 python3-pip python3-venv
Linux (Fedora / CentOS)
sudo dnf install python3 python3-pip
Part 4: pip: Use the package manager of Python
Python's real strength is in its libraries, such as requests, pandas, numpy, and flask. You can install these libraries using pip, Python's package installer, which is included with most Python installations.
Some basic commands:
pip install requests # Install a library
pip install requests==2.31.0 # Install a specific version
pip uninstall requests # Uninstall a library
pip list # List all installed packages
pip install --upgrade pip # Upgrade pip to the latest version
If the pip command is not execute then try it
python -m pip install requests
Part 5: Choosing an editor for writing code
You can use the editor for writing the python code some of them.
- IDLE: It is the beginner friendly editor supported to the python.
- VS Code: It is the free, lightweight, and most popular editor. You can install lightweight extensions and write the program.
- PyCharm Community Edition: It is the best for bade projects bade projects. It is free to download.
- Jupyter Notebook: It is best for data science and machine learning.
If you are beginner then i will recommend you to use VS Code. Once you learn it then switch any other tools.
Part 6: Virtual Environment (Intermediate)
Beginners often skip this topic, but virtual environments are an important part of professional Python development.
What is a Virtual Environment?
Suppose you have two Python projects. One project requires Django 3, while the other requires Django 5 then you install the both versions in the same environment but it can can cause a dependency conflicts.
A virtual environment solves this problem by providing each project with its own isolated Python environment, including its own set of installed libraries.
How to Create a Virtual Environment
Open your project folder in the terminal and run the following command:
python -m venv myenv
This command creates a folder named myenv inside your project directory. It contains the files needed to manage the virtual environment.
How to Activate a Virtual Environment
The activation command depends on your operating system and terminal.
Windows (Command Prompt):
myenv\Scripts\activate
Windows (PowerShell):
myenv\Scripts\Activate.ps1
macOS / Linux:
source myenv/bin/activate
Once the virtual environment is activated, you will see (myenv) at the beginning of your terminal prompt.
Now, whenever you install a library using pip install, it will be installed in the active virtual environment rather than the system-wide Python environment.
How to Deactivate a Virtual Environment
You can exit the virtual environment, run the following command:
deactivate
This returns your terminal to the default Python environment.
Working with requirements.txt
The requirements.txt file stores a list of the libraries installed in your project. It makes it easier to recreate the same development environment on another computer.
Step 1: Save the installed libraries
Run the following command to save the installed packages and their versions in a file named requirements.txt:
pip freeze > requirements.txt
Step 2: Install the libraries on another computer
You install all the libraries listed in requirements.txt, run the following commands:
pip install -r requirements.txt
It helps other developers to set up the same project environment without installing each library separately.
Part 7: Managing Multiple Python Versions (Advanced)
Sometimes, you may need to use different Python versions, such as Python 3.10 and Python 3.12, on the same computer. Several tools are available to install, manage, and switch between multiple Python versions.
- Python py Launcher (Windows): The Python launcher comes with Python on Windows. You can use py -3.12 to run a specific Python version and py -0 to view the list of installed Python versions.
- pyenv (macOS/Linux): This tool allows you to install and switch between different Python versions. For Windows, you can use pyenv-win.
- Conda / Miniconda: These tools are widely used in data science. They help manage Python versions, packages, and project environments.
- uv: A modern and fast tool for managing Python versions, packages, and virtual environments. It is worth exploring when starting new Python projects.
Frequently Asked Questions (FAQs)
Is Python Free to Install?
Yes, Python is completely free and open-source. You do not need to purchase a license or pay any fees to download, install, or use it.
Is an Internet Connection Required to Install Python?
You need an internet connection to download the Python installer and install additional libraries. However, once Python is installed, you can run basic Python programs without an internet connection.
What is the Difference Between Python 3 and the python Command?
On Windows, the python command usually works to run Python programs. On macOS and Linux, you often need to use python3 because the python command may point to an older or different Python version.
Should You Choose Between 32-bit and 64-bit Python?
Most modern computers use a 64-bit operating system. Therefore, you should generally download the 64-bit version of Python for better compatibility with modern systems.
Can You Run Python on a Mobile Phone?
Yes, you can run Python on an Android phone using apps such as Pydroid 3. However, a laptop or desktop computer is a better choice for learning Python and working on larger projects.
What Should You Learn After Installing Python?
After successfully installing Python, you can start learning Python Syntax. Then, move on to important beginner topics such as Comments, Variables, and Data Types.
Conclusion
Python installation is very easy only you should remind the checkbox button. After you can complete the basic setup, you should learn how to to use pip and virtual environment, as they will be useful in almost every environment.