Setting Up a Python Virtual Environment in VS Code (Without Conda)

Setting Up a Python Virtual Environment in VS Code (Without Conda)

If you’re working on a project and want to isolate your Python environment (without using Conda), this guide will walk you through setting it up in VS Code using native venv.

Pre-requisite: Python must be installed on your system.


🔧 Step-by-Step Setup

✅ STEP 1: Open VS Code and Terminal

  • Open VS Code
  • Press    command + `    to launch the terminal

📁 STEP 2: Create Your Project Directory

mkdir LLMEngg

cd LLMEngg


🛠️ STEP 3: Create a Virtual Environment

python -m venv LLMEngg


⚙️ STEP 4: Activate Virtual Environment in VS Code

  1. Open the Command Palette (⇧ + ⌘ + P or Ctrl + Shift + P)
  2. Search for and select: Python: Select Interpreter
  3. Choose: Python 3.12.4 ('LLMEngg')

📦 STEP 5: Create requirements.txt

vi requirements.txt

Add the following:

numpy

pandas

scikit-learn


♻️ STEP 6: Reopen VS Code (Important!)


🧪 STEP 7: Verify the Environment

In the terminal, check the Python path:

which python

Example output:

/Users/vamsi/Desktop/PREP/LLMEngg/LLMEngg/bin/python

Now install dependencies:

pip install -r requirements.txt


🧠 STEP 8 (Optional): Install PyTorch

pip3 install torch torchvision

Validate:

import torch

x = torch.rand(5, 3)

print(x)


🚀 Bonus: Speed Up Your Workflow

1️⃣ Set Alias in .zshrc (macOS)

alias llm="cd /Users/vamsi/Desktop/PREP/LLMEngg"


🔁 Reusing the Environment (Next Time)

  1. In terminal:

llm

  1. Launch VS Code:

code .

  1. Repeat interpreter selection:
  • Open Command Palette
  • Choose Python: Select Interpreter
  • Select: Python 3.12.4 ('LLMEngg')

🎉 You’re all set! This lightweight setup gives you a clean, isolated Python environment in just a few minutes — no Conda required.

vamsi manyam Avatar