[Python-Dev] Python REPL doesn't work on Windows over remote powershell session (winrm)

David Bolen db3l.net at gmail.com
Sat Aug 25 22:12:48 EDT 2018


ZHU Xiang <xiang.zhu at outlook.com> writes:

> ===================================
> Steps to reproduce
>
> # 1/ pre-install python on server1 (server 1 is a windows os)
> # 2/ from a powershell console on server0, type below 2 commands:
> enter-pssession server1
> python
>
> Expected behavior
> # The python >>> prompt appears
>
> Actual behavior
> # Nothing, it is still the powershell prompt
> ===================================

Still the powershell prompt or nothing at all?  If the latter, try using
"python -i" instead.  The "-i" will force interactive mode if stdin
isn't otherwise detected as interactive (under the covers, isatty() is
false for stdin), which is where I believe the issue is.

I've used that under Windows ssh sessions (though with cygwin rather
than powershell as well as some of my own remoting tools) for as long as
I can remember (certainly back to XP and Python 2.x - maybe 1.x) for an
interactive prompt when operating without a local windows console.

I'm not sure if there's any better way for Python to detect a remote
shell as being interactive under Windows that would cover such cases.
Perhaps some of the newer pty changes I read Microsoft is making might
help, assuming it flows through to the isatty() test.

-- David



More information about the Python-Dev mailing list