Venvs Part 3 - System Pollution, Conflicts, Reproducibility Issues

Venvs Part 3 - System Pollution, Conflicts, Reproducibility Issues

Okay so your interpreter is inside of your environment. The tutorial is about to go deep now. In its own words. HOORAY! I'm continuing with this.

Why do you need virtual environments?

I feel as if I have spent the whole morning addressing this. But... I didn't know this tutorial would be going deeper! Python isn't great at dependency management. If you're not specific then you will pip install all of your packages into an incorrect folder. "Several issues can come up" if all of your dependencies are in the same folder. So let's learn

About other problems that virtual environments protect us from...

A purple themed image with text that says virtual environments part 3

System Pollution

Linux and macOS both come with a version of Python that the OS uses for internal tasks.

Wait, what???? It's best not to install python packages into your system's global Python in case it interferes with some OS stuff. Wait, WHAT???! You don't want to break your OS!!! And you don't want your packages to get damaged if you update your OS.

Sidestep Dependency Conflicts

Perhaps the biggest motivation for using a virtual environment is that two different projects might require two different versions of the same dependency. If you only have one place to install packages, then you won't be able to work with different versions of the same library! This is one of the main reasons why have a venv is so important. Because you want to allow yourself to be working with multiple versions of the same dependency at once.

You can't have two different versions of a same package in a single Python environment. So you must have a different virtual environment for each project. This I have always grasped. Each virtual environment can have its own version of a package, e.g. Django. Sorry I got sidetracked - I am listening to the most beautiful song in the world - Baba Hanuman by Krishna Das. I'll just embed that here...


Holy moly - that's just so beautiful... I could listen to it forever

Reproducibility Issues

This is what would happen if you were sharing a virtual environment across multiple projects. But I don't do that... so... Ah got it. If you and other developers are working on the same thing... it is important to be able to reproduce environments and share dependencies. 

Obviously, this is what we do at work. Anywhere from 2 to 1000 developers can work on the same thing. You don't want to be going through lists of dependencies to find out what belongs to what. And with virtual environments, you don't have to do this.

Comments

Popular posts from this blog

Hello World

“But yesterday, I heard God say, you were born to be the one…”

In the Water, I find Fire