PYTHONPATH vs Python Virtual Environment

Dieter Maurer dieter at handshake.de
Fri Feb 4 14:25:33 EST 2022


Sina Mobasheri wrote at 2022-2-4 15:55 +0000:
>it's not good title defiantly and I don't mean to compare apples and oranges
>
>when I start using python virtual environment it was because isolation proposes and everyone say about its benefits in isolation and working with different versions of the same package in different projects
>
>but recently I start using pip install --target <package> for zipapp<https://docs.python.org/3.10/library/zipapp.html#creating-standalone-applications-with-zipapp> things, and then I use this pip's option (--target) and add its target folder to PYTHONPATH and target folder's bin directory to PATH, so it's like virtual environment to me
>
>I'm curious what is a problem with this approach (edges), what are other benefits of the virtual environment that this way can't offer? most tutorials talk about isolation and managing of packages versions but I think maybe it's more than that maybe?

Usually, PYTHONPATH is global.
This can make a problem when you have different applications
which require different package versions.

Of course, you can use a wrapper for your application which locally
sets PYTHONPATH appropriately.


More information about the Python-list mailing list