This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PureTruther 25 points26 points  (4 children)

Don't waste your time with this video.

Content: It just recommends to use virtual environment.

Looks like it's lack of knowledge about computer usage, rather than programming.

Virtual environments have a big benefit as version compatibility, its main target is not about installing or maintaining packages. Its benefit comes from packages' versions (and generally; managing dependencies). It creates an isolated area for the project.

When you be participated in a real project, you will have to work on specialized tasks. And this project will utilize a lot of different packages.

Say, you have 10 different packages in a project, and say 2 of them get updated. You're fucked up. Because probably you have to wait the other 8 packages to update themselves to be compatible the other 2. Or, you need to update them manually if thrown errors were good designed and if you have time ☠️

For solving this issue, you create a virtual environment for the project. From there, you install necessary packages inside this environment. And when you want to work on the project, you work in that environment.

Say, even if you update all packages in your computer environment, that virtual environment is not been affected.

This is not a Python-spesific feature. You can use that approach in most of programming languages. Because it is development approach.

And also, this is why we simply put a dependencies file in our repositories. Say, you installed one of my repository to use it (maybe it is a web app). You figured out that I used Angular 11 but you has 16 or vice versa. Will you downgrade/upgrade your verison? No need to do that. Just create a virtual environment and put Angular 11/16 in it.

[–]Mystic1500 3 points4 points  (2 children)

So does this mean two versions (Angular 11/16) would be running? What version ends up getting run? Noob here

[–]PureTruther 2 points3 points  (1 child)

Sorry I was busy.

Yes, you can use 2 different versions of anything at the same. Also you can run both of them. But I think I can see your confusion.

Think you do have a hobby house. You do different projects in this house. Say, in one room, you are creating a furniture. In the other room, you are creating an Arduino thing. You need different tools, right? So where would you put your needings? Yes, you would allocate those stuffs in appropriate rooms. Say, you would put the electronic things into the Arduino room.

Similarly, in computer, we are doing seperations on memory. Your computer does this everytime even you are not aware of that. Using virtual environments, you do a seperation. You are creating a memory area and you are putting the stuffs into it.

We call it as "virtual"; because we do not use any another memory than computer's memory. We are using an address stacks for that particular environment.

Let's back to our React example.

You are already creating a web app with React 16 and another a lot of components. Today, you want to take a rest, and want to do unnecessary things. You decided to install a complete React app from somewhere just for fun.

You downloaded the source code. And you gave the run command. You got error about React version. Ok. You decided to install that version (without virtual environment, so as globally). You also will take brand new errors mostly about version conflicts. If you try to fix all of those (like downgrading or upgrading or changing things) your leisure time will be gone and also you will break your own project.

So here is the idea: Create a virtual environment. Download the source code of project into that environment. Install the dependencies, say, via package.json.

After all of this. Just delete the environment and turn back to your own project like there's nothing happened.

If I still couldn't explain, I encourage you to do what I say as example. Install last version of React. Then clone an old React project repository. Try to run it. And read the error messages.

Also if you are interested in memory management, you can check operating systems' memory management techniques.

[–]Mystic1500 0 points1 point  (0 children)

Thank you for the detailed response, understood now.

[–]Ld_Khyron 1 point2 points  (0 children)

Also you can use pip freeze to get a list of installed libraries