The node_modules culture shock: How I accidentally broke my system with Python
The Virtual Environment Guide for Newbie Python Developers.
The “Wait, what?” Moment
If you come from the JavaScript or Node.js world, you are incredibly spoiled. You clone a repository, you type
npm installoryarn, and a massive folder callednode_modulesappears right inside your project.
It is beautiful. It is self-contained. If the project breaks, you delete that folder and start over. If you delete the project, the dependencies go into the trash with it.
So, naturally, when I started learning Python, I figured pip worked exactly the same way.
I found a cool package, opened my terminal, and typed:pip install requests
It worked perfectly! I felt like a genius.
Then a week later, I started a second Python project. This one needed a completely different, older version of that same requests package. I ran pip install requests==2.20.0. It worked again!
But when I went back to my first project? Totally broken. Crashed instantly.
That was the moment I realised:pip does not care about your project folder. By default, it installs everything globally.
The Global Trap
When you run pip install, Python drops those packages straight into your core operating system files. Every single Python script on your computer now shares that exact same package.
If Project A needs Version 3, and Project B needs Version 1, they will fight to the death. Whichever one you installed last wins, and the other project breaks.
To fix this and get that clean, isolated npm feeling, you have to use what Python calls 'virtual environments'. Think of them as tiny, isolated sandbox bubbles for your projects.
Here are the two ways I learned to build these bubbles.
Method 1: The .venv Folder (The closest thing to node_modules)
Python actually has a tool built right into it called venv. It creates a local folder inside your project directory to hold your packages, just like Node does.
Here is how you use it:
Get Neeraj Chaudhary’s stories in your inbox
Join Medium for free to get updates from this writer.
1. Create the folder
Open your terminal in your project root folder and run:python -m venv .venv
(This creates a folder named .venv. You can name it anything, but .venv is standard).
2. The Catch: You have to turn it on
With Node, you just run commands and it automatically knows where node_modules is. Python is not that smart. You have to explicitly tell your terminal, "Hey, look inside my bubble!"
- If you are on a Mac or Linux:
source .venv/bin/activate - If you are on Windows:
.venv\Scripts\activate
You will see (.venv) appear at the start of your terminal line. That means you are safely inside the bubble. Now, when you run pip install, the packages go into that folder, not your global system.
3. Leaving
When you are done working, just type deactivate to step back out.
Method 2: Conda (The Data Science Heavyweight)
As you look at Python tutorials, you will inevitably see people talking about Conda or Anaconda.
Conda is a bit different. While venv only handles Python packages, Conda is built for data science and AI. It can manage Python versions and even non-Python stuff (like heavy C++ math libraries or graphics card drivers for AI).
Unlike venv, Conda does not put a folder inside your project directory. It keeps all your bubbles hidden away in a central location on your computer.
Here is the Conda workflow:
1. Create the environment by name
Instead of pointing to a folder, you give it a name and tell it which version of Python you want:conda create --name my_cool_project python=3.11
2. Activate it
Just like venv, you have to turn it on:conda activate my_cool_project
3. Install stuff
Now you can install your packages safely:conda install numpy
Which one should you use?
- If you are just writing normal Python scripts, building a web app, or want something lightweight that feels like
npm→ Usevenv. - If you are diving into machine learning, data science, or playing with AI models → Use Conda.
The Takeaway
Switching languages always comes with weird mental speedbumps. If you are new to Python, save yourself the headache I had: Never run pip install until you see that little environment name in your terminal prompt.
Keep your projects in their bubbles, and your system will stay clean!






