Python Virtual Environment
  • Setting Up Your Python Playground
  • Install packages using pip
Powered by GitBook
On this page
  • Before You Begin: Requirements
  • Choose Your Python Playground
  • Step Inside Your New Space
  • Time to Build Your Digital Fort
  • Activate Your Virtual Adventure Zone
  • Exit Your Coding Oasis

Setting Up Your Python Playground

NextInstall packages using pip

Last updated 10 months ago

Welcome to our inaugural quick code guide! Today, we're diving into a fundamental skill for Python developers - setting up a virtual environment.

Picture this: Your own dedicated space, free from the clutter of conflicting packages, where you can experiment, create, and innovate with Python. That's exactly what a virtual environment offers. It's like having your very own laboratory, tailor-made for Python projects.

In this step-by-step guide, we'll walk you through the process of creating a virtual environment, enabling you to work on multiple projects with different dependencies, without any interference. Whether you're a beginner or a seasoned developer, mastering this skill is essential for efficient Python programming.

Ready to unlock the full potential of Python in your projects? Let's get started on this exciting journey!

Before You Begin: Requirements

Before you dive into this guide, make sure you have the following:

  • Terminal or Command Prompt: Familiarize yourself with your system's terminal or command prompt. This guide assumes you have a basic understanding of using the command line.

  • Text Editor: Have a text editor of your choice installed for writing and editing Python code. Popular choices include Visual Studio Code, Sublime Text, or Atom.

  • A Sense of Adventure: Approach this guide with curiosity and a willingness to explore. Coding is an adventure, and every challenge is an opportunity to learn!

Choose Your Python Playground

Open your terminal and navigate to the directory where you're going to create your Python project. Create a folder by runing the command:

mkdir python_project
mkdir python_project

Step Inside Your New Space

Step into your freshly minted folder:

cd python_project
cd python_project

Time to Build Your Digital Fort

It's time to create a secret hideout, known as a virtual environment, for your Python adventures. Depeding on the python version you have installed on your machine, execute:

python -m venv .venv
py -m venv .venv

The dot at the beginning of .venv makes this folder magically hidden!, which is a good practice.

Activate Your Virtual Adventure Zone

Activate your virtual environment to start your coding journey in isolation. Run the following command:

source .venv/bin/activate
.venv\Scripts\activate

You will notice that your comand line will start with (.venv) which means you are currently working inside a virtual environment.

Exit Your Coding Oasis

When you're done for the day, deactivate your virtual environment. You'll know it's done when (.venv) disappears from your terminal, run the comand:

deactivate

Python Installed: Ensure you have Python installed on your system. You can download it from the official website.

python