link to venv python sees a different sys.path

Robin Becker robin at reportlab.com
Wed Mar 11 11:26:44 EDT 2020


I'm trying to understand why python 3.8.2 venv behaves differently when it is executed va a link

Make the env
> rptlab at everest:~/code/hg-repos
> $ python38 -mvenv __py__/382v
> rptlab at everest:~/code/hg-repos

make a link
> $ ln -s ../__py__/382v/bin/python bin/python382v

the venv sys.path
> rptlab at everest:~/code/hg-repos > $ __py__/382v/bin/python -c"import sys;print('\n'.join(sys.path))"
> 
> /home/rptlab/LOCAL/382/lib/python38.zip
> /home/rptlab/LOCAL/382/lib/python3.8
> /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload
> /home/rptlab/code/hg-repos/__py__/382v/lib/python3.8/site-packages
> rptlab at everest:~/code/hg-repos

the linked python sys.path
> $ bin/python382v -c"import sys;print('\n'.join(sys.path))"
> 
> /home/rptlab/LOCAL/382/lib/python38.zip
> /home/rptlab/LOCAL/382/lib/python3.8
> /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload
> /home/rptlab/LOCAL/382/lib/python3.8/site-packages
> rptlab at everest:~/code/hg-repos
> $ 

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.

This problem doesn't seem to occur with older virtualenv made environments.
--
Robin Becker


More information about the Python-list mailing list