PYTHONPATH priority after standard library?

I think PYTHONPATH is designed to be used in the application context, so it makes sense it only serves that well, and have issues when used elsewhere. The problem, from what I understand from the above, is that there is no way to specify “append after stdlib but before site-packages” without diving into sys.path (which isn’t trivial since the paths themselves don’t say why they end up in there, so a bit guess work is required). Maybe the solution is to provide a mechanism for that scenario, instead of trying to change PYTHONPATH to do what it wasn’t designed to do.

The Interpreter independent isolated/virtual environments thread a while ago raised a similar need (virtual environment site-packages directory is appended after stdlib; the “before site-packages” part is relevant for system-site-packages = true), so there is definitely a valid use case for this.

1 Like