Skip to main content

Command Palette

Search for a command to run...

The Isolated Serpent

Virtual Environments In Python

Updated
2 min read
The Isolated Serpent
T
I document the weird thresholds of programming—turning confusion into clarity through annotated scrolls, beginner rituals, and product flows. From API-fetching to ergonomic selection, every scroll is a teachable moment. TheCodedHuman isn’t a title—it’s a mindset. A ritual alignment to the work we’re truly meant to do.

Python got Virtual Environment ?

Yup. Python doesn’t just run code—it builds chambers for it. These chambers are called virtual environments, and they help isolate your project from the chaos of the outside system.

In Python, you can:

  • Create a virtual environment using python -m venv <name>

  • Activate it to step inside the chamber

  • Install libraries without polluting your system

  • Run your code in peace, then deactivate when done

It’s like building a glass terrarium for your code—everything inside is yours to control, and nothing leaks out.


So, How can I create and start working with Virtual Environment In Python ?

Virtual Environment Creation By Command Prompt In Windows:

  1. Open Command Prompt

  2. Go To Folder Location

     cd /d "<folder_location>"
    
  3. Setup and create Python Interpreter and Environment

     python -m venv <environment_name>
    

    OR

     py -<python_version> -m venv <environment_name>
    
  4. Activate the Virtual Environment

     .\<same_environment_name>\Scripts\activate
    
  5. You can also install isolated libraries in that as follows:

     pip install <package_name>
    
  6. File creation method are shown in below topics, write some code, save your changes, and close the file.

  7. After working you can deactivate the Environment by:

  8.     deactivate
    

Directly closing an activated Virtual Environment will lead to deactivating it, but it is considered better practice to deactivate it manually.


Critical Adjustments to Encounters

In Windows, a security protocol prevents scripts from manipulating the internal workings of the computer. As a result, it becomes necessary to bypass this security protocol as follows:

  1. Temporary Fix (Instance Based):

     Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    
  2. Safer Fix (Directory Based)

     Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    
  3. Permanent Fix (User Based)

     Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    

🧱 Where to Create Files (and src/)

You’ve already activated the virtual environment using:

.\<environment_folder_name>\Scripts\activate

Now, do not place your code inside environment_folder_name/. That folder is sacred—it holds the chamber’s internals.

Instead, create your src/ folder next to environment_folder/, like this:

<parent-folder>/
├── <virtual_environment_folder>/           ← virtual environment (don’t touch)
├── src/                                    ← your code lives here
│   └── <file_x>.py
└── <or_file_y>.py                          ← or even in parent-folder itself

You can run your script like this:

  •     python <file_name>.py
    

OR

  •     python .\<file_name>.py
    

And since your virtual environment is activated, any pip install will go into environment_name/Lib/site-packages, safely isolated.

More from this blog

CodeTerrarium

2 posts

If you’ve ever installed a library and watched your system descend into chaos, welcome to this blog. CodeTerrarium: where your code can breathe without polluting the outside world.