I am trying to run python interpreter with modified sys.path. This is normally done by setting the PYTHONPATH environment variable. I understand wenv cannot do this due to path translation when called from Linux shell:
$ PYTHONPATH=foo:bar python -c'import sys; print(sys.path)'
['', '/home/eudoxos/foo', '/home/eudoxos/bar', '/usr/lib/python310.zip', '/usr/lib/python3.10', # ....
$ PYTHONPATH='foo;bar' wenv python -c'import sys; print(sys.path)'
['C:\\python-3.8.5.stable\\Lib', 'C:\\python-3.8.5.stable', 'C:\\python-3.8.5.stable\\lib\\site-packages']
# where is foo and bar?
But now I have a script running under wenv, which runs a child python process, wanthing to pass it some paths through its environment PYTHONPATH. This work both under Linux and under Windows, but not under wenv. The one-liner is like this (explanation: the main python calls another python as subprocess, passing it PYTHONPATH through an argument to subprocess.call):
$ wenv python -c "import sys, subprocess; subprocess.call([sys.executable,'-c','import sys; print(sys.path)'],env={'PYTHONPATH':'foo;bar'})"
['C:\\python-3.8.5.stable\\Lib', 'C:\\python-3.8.5.stable', 'C:\\python-3.8.5.stable\\lib\\site-packages']
# where is foo and bar?
As I checked, sys.executable is correct in the main interpreter:
$ wenv python -c'import sys; print(sys.executable)'
C:\python-3.8.5.stable\python.exe
Any ideas?
I am trying to run python interpreter with modified sys.path. This is normally done by setting the PYTHONPATH environment variable. I understand wenv cannot do this due to path translation when called from Linux shell:
But now I have a script running under wenv, which runs a child python process, wanthing to pass it some paths through its environment
PYTHONPATH. This work both under Linux and under Windows, but not under wenv. The one-liner is like this (explanation: the main python calls another python as subprocess, passing it PYTHONPATH through an argument tosubprocess.call):As I checked,
sys.executableis correct in the main interpreter:Any ideas?