Opening Python from within linux using Windows Terminal command line arguments causes it to use the Windows installation of python instead of linux's #13848
Replies: 6 comments
|
Ahh okay I see what's happening here.
You might be able to workaround this for now with See also #5528 |
|
So this kind of works but not really. I ran into a couple of problems.
What I'm actually trying to do is use Python subprocesses via Popen to launch multiple python scripts within Windows Terminal (using WT's tabbing and panes to organize the running processes)... Now, after some fiddling I got this to work, except that some of these scripts also use subprocesses to run linux-specific commands such as grep, which are not recognized as commands, since the wt commandline I used to launch the script is actually using Windows, which of course won't recognize the linux commands. |
|
Hey, sorry I lost track of this.
I bet that has something to do with launching the application directly, rather than via a login shell. Methinks that Python 3.10.4 is probably installed only for the default user's path, but the Python 3.8.10 version is available globally as python3. That's conjecture, and I don't totally know how paths are resolved in this case. Sounds like you sorta figured this out, sorta didn't. Did you think #5528 would help with the last bits of your use case here/? |
|
So it's been a while since I looked at this, but it seems that your solution did solve the inability to append arguments to the command, but the root problem for me ended up being that WSL still seems to be using the Windows version of Python on some level since it is being called from command prompt. This might be a related but different issue than the one I was originally facing, I'm not sure. I'm just going to post the code I was working with, in case that helps: Code files (can't post .py files): This was obviously a work in progress but it should get the idea across. If you try to run grep-sub.py as a subprocess in this script (from Ubuntu in WT), it doesn't recognize grep, but if you run it directly from the shell, it does. This leads me to think the subprocess is being run under the Windows environment rather than the Linux one. EDIT: Sorry, the reference to "test.py" on line 5 of grep-sub.py should be "working.py" |
|
Yea, that looks like you're just passing This definitely seems like another use case for #5528. I'm gonna call this a "dupe", but actually move this to a discussion thread. Thanks! |
|
it should also work and can be implemented in a string to run the command |







Uh oh!
There was an error while loading. Please reload this page.
Windows Terminal version
1.12.10982.0
Windows build number
10.0.19044.1645
Other Software
python27
python3.10
Ubuntu 20.04.2 LTS
Steps to reproduce
From Ubuntu in Windows Terminal, run the command:
cmd.exe /c "wt.exe" -p "Ubuntu" python pythonpath.pypythonpath.py
from time import sleepimport sysprint(sys.path)sleep(60)Now run the script on its own:
python pythonpath.pyCommand line arguments for doing this were found in the Microsoft documentation.
Expected Behavior
When a python script is run from within a linux subsystem, it uses the subsystem's python installation.
Actual Behavior
When the same script is run using Windows Terminal command line arguments, it is run using the the windows installation of python, despite correctly opening in a linux terminal.
All reactions