link to venv python sees a different sys.path
Jon Ribbens
jon+usenet at unequivocal.eu
Wed Mar 11 12:23:46 EDT 2020
On 2020-03-11, Robin Becker <robin at reportlab.com> wrote:
> I'm trying to understand why python 3.8.2 venv behaves differently
> when it is executed va a link
Because site.py contains a function called venv() which looks up the
path of the executed python binary, and searches for the virtual
environment relative to that path. If you're executing the python
binary via a link, it will look relative to the link, not the
target of the link.
> so the linked version of the venv python sees the base python site
> packages and not the expected venv site-packages.
>
> Is there a way to make the link work properly.
No. Unless you count making a shell script in the place you want which
does nothing except exec the python binary inside the venv, i.e.:
cat >pythonish
#!/bin/sh
exec some/other/python "$@"
^D
More information about the Python-list
mailing list