codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐍

Python Programming

2 / 68 topics
1Python Introduction & Features2Python Get Started & VirtualEnv3Python Syntax & First Program4Python Comments & Keywords5Python Variables & Constants6Python Basic Input and Output
Tutorials/Python Programming/Python Get Started & VirtualEnv
🐍Python Programming

Python Get Started & VirtualEnv

Updated 2026-04-20
3 min read

Introduction

Python is a versatile, high-level programming language known for its readability and simplicity. It's widely used in various domains such as web development, data analysis, artificial intelligence, scientific computing, and more. This tutorial will guide you through the basics of setting up Python on your system and using virtualenv to manage project-specific dependencies.

Prerequisites

Before we dive into the setup, ensure that you have the following:

  • A computer with internet access.
  • Basic understanding of command-line interfaces (CLI).

Installing Python

Python can be installed from the official website or through package managers. Here’s how you can install it on different operating systems.

On Windows

  1. Download the Installer:

    • Visit the official Python website.
    • Download the latest version of Python for Windows.
  2. Run the Installer:

    • Open the downloaded installer.
    • Ensure you check the box that says "Add Python to PATH" before clicking "Install Now."
  3. Verify Installation:

    • Open Command Prompt and type:
      python --version
      
    • This should display the installed version of Python.

On macOS

  1. Using Homebrew (Recommended):

    • If you don't have Homebrew, install it by following the instructions on Homebrew's website.
    • Install Python using Homebrew:
      brew install python
      
  2. Verify Installation:

    • Open Terminal and type:
      python3 --version
      
    • This should display the installed version of Python.

On Linux

  1. Using Package Manager:

    • For Ubuntu/Debian-based systems, use:
      sudo apt update
      sudo apt install python3
      
    • For Fedora, use:
      sudo dnf install python3
      
  2. Verify Installation:

    • Open Terminal and type:
      python3 --version
      
    • This should display the installed version of Python.

Setting Up Virtual Environment

A virtual environment is an isolated Python environment that allows you to manage dependencies for different projects separately. This prevents conflicts between project-specific packages.

Installing virtualenv

virtualenv can be installed using pip, Python's package installer.

pip install virtualenv

Creating a Virtual Environment

  1. Navigate to Your Project Directory:

    • Open your terminal or command prompt.
    • Navigate to the directory where you want to create your project:
      cd path/to/your/project
      
  2. Create a Virtual Environment:

    • Run the following command to create a virtual environment named env:
      virtualenv env
      
    • Alternatively, you can use Python's built-in module:
      python3 -m venv env
      

Activating the Virtual Environment

  • On Windows:

    .\env\Scripts\activate
    
  • On macOS/Linux:

    source env/bin/activate
    

Once activated, your command prompt or terminal will show the name of the virtual environment (e.g., (env)), indicating that it's active.

Deactivating the Virtual Environment

To deactivate the virtual environment and return to the global Python environment, simply run:

deactivate

Managing Dependencies with pip

pip is the package installer for Python. It allows you to install and manage additional libraries and dependencies.

Installing Packages

With your virtual environment activated, you can install packages using pip. For example, to install the popular web framework Flask:

pip install flask

Listing Installed Packages

To see all installed packages in your current virtual environment:

pip list

Freezing Dependencies

To create a requirements.txt file that lists all installed packages and their versions, use:

pip freeze > requirements.txt

This file can be used to replicate the environment on another machine or for future reference.

Best Practices

  • Always Use Virtual Environments: This ensures that your project dependencies are isolated from other projects.
  • Keep requirements.txt Updated: Regularly update this file to reflect any changes in your project's dependencies.
  • Use Version Control Systems (VCS): Tools like Git help manage changes and collaborate with others effectively.

Conclusion

Congratulations! You have successfully set up Python on your system and learned how to use virtualenv to manage project-specific dependencies. This setup is essential for developing robust and maintainable Python applications. In the next sections of this course, we will explore more advanced topics in Python programming.


PreviousPython Introduction & FeaturesNext Python Syntax & First Program

Recommended Gear

Python Introduction & FeaturesPython Syntax & First Program