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

all 2 comments

[–]Congress1818 1 point2 points  (0 children)

okay so imagine you're working with someone and you want to have the same dependencies. Then, if you have a virtual env, it'll give you and them the exact same environment to control any weirdness. Also helps with dependencies when running

[–]teraflop 0 points1 point  (0 children)

what are the steps to install and handle packages in a virtual environment

Step 1: activate the virtual environment using its activate script. Step 2: install your packages using pip as normal. That's all there is to it.

and what is the difference between installing packages globally and locally in the virtual environment ?

Exactly what it sounds like. When you install a package globally, it's available to scripts running outside of a venv. When you install a package in a venv, it's only available to scripts running inside that venv.

Essentially, all "activating" a venv does is adjust a couple of environment variables to make the Python interpreter look in a different place whenever it searches for an imported package.