Print

Print


> personally i fail to see difference between --user pip install and an always activated default venv

There are three main benefits to virtual environments
## Compatibility 
The difference is more pronounced when you have multiple environments. Even if you're only ever using one environment, though, there are similar benefits. If you have Python tools (e.g. `poetry`/`pdm`, `tox`/`nox`, `black` etc) installed into the same environment, you eventually will run into the scenario where you cannot update your libraries because one of the packages imposes an upper-bound on the version Even though upper limits [are not best practice](https://iscinumpy.dev/post/bound-version-constraints/) in Python, they still exist in the wild, and can cause these problems. Worse, you can end up with two packages with incompatible version constraints (e.g. `scipy` wants a newer `numpy` than some other library). Virtual/Conda environments avoid this by allowing you to separate distinct packages into their own environments. 

Related to this is `pipx`, which lets you install Python "applications" (libraries that you're not really expected to import from Python, e.g. `pip` or `black`) in their own separate environments, but launch them without activating the env.

## Safety
Sometimes you can break your environment, especially when using `pip` directly instead of a project manager like `pdm` or `poetry`. Virtual environments make this less problematic - you can easily delete and recreate the environment, and only have to re-install those packages which were installed in that particular environment.

## Python Version
With Conda environments (or virtualenvs if you use something like `pyenv`), you can install a different version of Python to that of your system. This is generally useful.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/1668#issuecomment-1088462506
You are receiving this because you are subscribed to this thread.

Message ID: <[log in to unmask]>

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1