Using Wing on Windows with python from a backing WSL

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Has anybody tried using Wing on Windows, but having the python executable using a python that resides inside the WSL (Windows Subsystem for Linux)?

Executing python from inside a WSL distro is as easy as:

wsl /path/tp/your/python

... but Wing won't take any of these lines for a python executable in project properties:

wsl /path/to/my/python
C:\Windows\System32\wsl.exe /path/to/my/python

I tried putting one of those into a batch file to see if Wing's issue was the space in the path, but it is apparently/unfortunately more than that.

Running Wing from inside the WSL, together with VcXsrv as the X server, is not 100% terrible as a workaround to enable linux development on a Windows machine without needing a VM... but it would definitely be better to run from Windows proper and just use the WSL python.

Thanks!
Russ


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Russell Warren via wingide-users wrote:
Has anybody tried using Wing on Windows, but having the python executable using a python that resides inside the WSL (Windows Subsystem for Linux)?

Executing python from inside a WSL distro is as easy as:

wsl /path/tp/your/python

... but Wing won't take any of these lines for a python executable in project properties:

wsl /path/to/my/python
C:\Windows\System32\wsl.exe /path/to/my/python

I tried putting one of those into a batch file to see if Wing's issue was the space in the path, but it is apparently/unfortunately more than that.

Running Wing from inside the WSL, together with VcXsrv as the X server, is not 100% terrible as a workaround to enable linux development on a Windows machine without needing a VM... but it would definitely be better to run from Windows proper and just use the WSL python.

It appears you can ssh into WSL so you could set that up as a remote host using the newer remote development support in Wing 6:  https://wingware.com/doc/proj/remote-hosts

I'm not familiar with how the file system for WSL works but it's also conceivable that it may work to apply the same general approach as in https://wingware.com/doc/howtos/cygwin

Please let me know if this does not help.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com



_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Simply running the executable should be doable with a batch file that forwards all arguments

Wing does not like getting a batch file as the python executable.  I made a batch file (at c:\pcode\edms\wslpython.bat ) with this in it:

C:\Windows\System32\wsl.exe /home/russ/miniconda3/envs/edms/bin/python %*

where that command (minus the `%*` arg forwarding) works 100% perfectly from a cmd.exe shell, and Wing throws this "Invalid Properties" error dialog:

Some values are invalid:

- Could not launch or inspect Python executable 'c:\pcode\edms\wslpython.bat'. It should be the name of a Python interpreter that is on your PATH (such as python, python3.4, python.exe) or the full path to the Python interpreter you wish to use.

Please correct the values and try again.

You also asked:

 How does WSL handle paths though? The win32 build of the debugger assumes windows style paths with drive letters and \'s.

There may be some issues here, but it depends what you need.  There are a bunch of tidbits on path handling with WSL, so I'll just spew a bunch:
  • when you run `wsl python` from Windows it is as if you are running python from inside the WSL instance... kind of like a VM.
    • All paths are relative to the WSL filesystem root, very much like with cygwin (so `/proc` exists for the python interpreter)
    • Python thinks it is running in linux.  e.g. sys.platform == 'linux2'
    • `C:\` is available as `/mnt/c` (although you can now rename this using an `/etc/wsl.conf file`)
  • The PATH env var itself is sensibly available from within WSL (e.g. `C:\Windows\System32` maps properly across to `/mnt/c/Windows/System32`)
  • Linux/WSL has no problem accessing Windows files through `/mnt/c`, but Windows can't cleanly access the linux filesystem
    • As a result of this, it is typical to store project files out in Windows and just symlink from your home dir (or wherever)
    • Inheritance of file ownership and permissions are bit weird (lots of root:root), but this is MUCH better now
  • Path issues seem like they should definitely be resolvable...
    • The vscode guys definitely resolved it so you can run vscode in Windows, and node.js running on WSL. See here.
  • Microsoft now provides a `wslpath` utility for converting paths correctly inside the WSL
    • See Interoperability here: https://blogs.msdn.microsoft.com/commandline/2018/03/07/windows10v1803/
    • If, for example, there was a "python on WSL" checkbox in project properties, all Windows paths could be converted for the project's python executable using something like `wsl wslpath 'C:\code\foo.py'`
      • This should always work, since the files need to be on the Windows side for Wing to see them when run in Windows
  • environment variables can now be neatly exchanged with some magic
Worth noting is that a bunch of the WSL niceties above (filesystem improvements, wslpath, etc) do require the latest Win10 build (1803) to work. Not everyone has this.

It also uses win32 api calls, which may or may not be an issue.

No idea.  Seems like none should be project related since you can remotely debug, though... no?

You might need to treat WSL as a different machine and use wingdbstub and external launching like with cygwin.  There a howto for cygwin at https://wingware.com/doc/howtos/cygwin

Hopefully not... I glaze over a bit when looking at that method. :)  I kind of hoped that it would just work if I could specify the python exe inside WSL.  Thinking (likely oversimplified) was that Wing-on-Windows is just a great IDE run by your captive python, and all project/code python stuff would be handled by the executable specified in the project properties.  Not sure how clean that separation is, though.  The aforementioned wslpath conversions seem like they are probably essential to provide to the project's python executable.

The blend of Windows GUIs with a backing WSL is proving to be a really interesting development environment, so it wold be awesome if I could get Wing to cooperate with it without needing to run Wing on WSL with an X server!

Russ



_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Russell Warren via wingide-users wrote:

>     You might need to treat WSL as a different machine and use
>     wingdbstub and external launching like with cygwin.  There a howto
>     for cygwin at https://wingware.com/doc/howtos/cygwin
>
>
> Hopefully not... I glaze over a bit when looking at that method. :)  I
> kind of hoped that it would just work if I could specify the python exe
> inside WSL.  Thinking (likely oversimplified) was that Wing-on-Windows
> is just a great IDE run by your captive python, and all project/code
> python stuff would be handled by the executable specified in the project
> properties.  Not sure how clean that separation is, though.  The
> aforementioned wslpath conversions seem like they are probably essential
> to provide to the project's python executable.

I don't think there's much hope for running wsl's python directly
without the complexity of something like the cygwin instructions,
although configuration could possibly be automated.

I think it would be simpler to set up ssh into WSL and then use the new
remote development support described at
http://wingware.com/blog/remote-development and documented in more
detail at http://wingware.com/doc/proj/remote-hosts

I've put adding a How-To and support for WSL on our list of things to
look at in the near(ish) term.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Is there some way to select what ssh client Wing uses? Docs seem to say it will be either plink or ssh, but I don't see how to select it.

I can't get Wing working remotely (to my local).  This works 100% perfectly from Windows cmd.exe:

ssh localhost -i c:\Users\Russ\.ssh\id_rsa -p 1018

But this Wing setup gives me an error (with hostname as localhost):



This is the error I get:

The remote agent could not be installed on host id WSL local. Could not determine OS type (err=1).

PuTTY is prompting for a login name. Please add username@ to your Host Name in the remote host configuration. Or, you can create a saved session for your host in putty.exe, set the Connection > Data > Auto-login username, and then save the session.

Output received:

Unable to use key file "c:\Users\Russ\.ssh\id_rsa" (OpenSSH SSH-2 private key (old PEM format)) 
login as: FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey) 

I don't even have PuTTY installed, and I don't see a private copy inside Wing anywhere, so this seems like a buggy message?

Also confusing is that prior combinations (that I can't restore right now for some reason) have made it seem like Wing was using plink.exe. Wing even gave me an explicit plink.exe command to try to replicate to get past the authorized keys thing, but I don't have plink.exe on my path anywhere, so no dice.  I did end up searching my machine for it there's a copy of plink.exe tucked away somewhere that Wing was using, but all I could find was some plink.exe instances in my X server dirs (Xming and VcXsrv), but it seems unlikely to me that Wing located those ones. I see no captive copy, either.

Any help here is much appreciated!  Ideally I'd just tell wing to use the ssh that comes with my Windows (at C:\Windows\System32\OpenSSH\ssh.exe), but that is a fairly recent development so maybe I'm being optimistic?

Thanks,
Russ


On Thu, May 31, 2018 at 8:44 AM, Wingware Support <[hidden email]> wrote:
Russell Warren via wingide-users wrote:
    You might need to treat WSL as a different machine and use
    wingdbstub and external launching like with cygwin.  There a howto
    for cygwin at https://wingware.com/doc/howtos/cygwin


Hopefully not... I glaze over a bit when looking at that method. :)  I
kind of hoped that it would just work if I could specify the python exe
inside WSL.  Thinking (likely oversimplified) was that Wing-on-Windows
is just a great IDE run by your captive python, and all project/code
python stuff would be handled by the executable specified in the project
properties.  Not sure how clean that separation is, though.  The
aforementioned wslpath conversions seem like they are probably essential
to provide to the project's python executable.

I don't think there's much hope for running wsl's python directly without the complexity of something like the cygwin instructions, although configuration could possibly be automated.

I think it would be simpler to set up ssh into WSL and then use the new remote development support described at http://wingware.com/blog/remote-development and documented in more detail at http://wingware.com/doc/proj/remote-hosts

I've put adding a How-To and support for WSL on our list of things to look at in the near(ish) term.


Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com




--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Aha... missed this in your docs:

If Wing cannot find ssh or plink.exe you will need to add its directory to your PATH or set the Network > SSH Executable preference in Wing to the full path of the command. If this is set, Wing also tries to find scp (or pscp.exe on Windows with PuTTY) in the same directory as the specified executable.

I'll try that.


On Tue, Jun 5, 2018 at 9:56 AM, Russell Warren <[hidden email]> wrote:
Is there some way to select what ssh client Wing uses? Docs seem to say it will be either plink or ssh, but I don't see how to select it.

I can't get Wing working remotely (to my local).  This works 100% perfectly from Windows cmd.exe:

ssh localhost -i c:\Users\Russ\.ssh\id_rsa -p 1018

But this Wing setup gives me an error (with hostname as localhost):



This is the error I get:

The remote agent could not be installed on host id WSL local. Could not determine OS type (err=1).

PuTTY is prompting for a login name. Please add username@ to your Host Name in the remote host configuration. Or, you can create a saved session for your host in putty.exe, set the Connection > Data > Auto-login username, and then save the session.

Output received:

Unable to use key file "c:\Users\Russ\.ssh\id_rsa" (OpenSSH SSH-2 private key (old PEM format)) 
login as: FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey) 

I don't even have PuTTY installed, and I don't see a private copy inside Wing anywhere, so this seems like a buggy message?

Also confusing is that prior combinations (that I can't restore right now for some reason) have made it seem like Wing was using plink.exe. Wing even gave me an explicit plink.exe command to try to replicate to get past the authorized keys thing, but I don't have plink.exe on my path anywhere, so no dice.  I did end up searching my machine for it there's a copy of plink.exe tucked away somewhere that Wing was using, but all I could find was some plink.exe instances in my X server dirs (Xming and VcXsrv), but it seems unlikely to me that Wing located those ones. I see no captive copy, either.

Any help here is much appreciated!  Ideally I'd just tell wing to use the ssh that comes with my Windows (at C:\Windows\System32\OpenSSH\ssh.exe), but that is a fairly recent development so maybe I'm being optimistic?

Thanks,
Russ


On Thu, May 31, 2018 at 8:44 AM, Wingware Support <[hidden email]> wrote:
Russell Warren via wingide-users wrote:
    You might need to treat WSL as a different machine and use
    wingdbstub and external launching like with cygwin.  There a howto
    for cygwin at https://wingware.com/doc/howtos/cygwin


Hopefully not... I glaze over a bit when looking at that method. :)  I
kind of hoped that it would just work if I could specify the python exe
inside WSL.  Thinking (likely oversimplified) was that Wing-on-Windows
is just a great IDE run by your captive python, and all project/code
python stuff would be handled by the executable specified in the project
properties.  Not sure how clean that separation is, though.  The
aforementioned wslpath conversions seem like they are probably essential
to provide to the project's python executable.

I don't think there's much hope for running wsl's python directly without the complexity of something like the cygwin instructions, although configuration could possibly be automated.

I think it would be simpler to set up ssh into WSL and then use the new remote development support described at http://wingware.com/blog/remote-development and documented in more detail at http://wingware.com/doc/proj/remote-hosts

I've put adding a How-To and support for WSL on our list of things to look at in the near(ish) term.


Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com




--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.



--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Some progress, but now a different error I can't figure out.  Setting the ssh excutable to my local ssh.exe yields this error:

The remote agent could not be installed on host id WSL local. Could not determine OS type (err=None).

Output received:

Failed to start command line: ['C:\\Windows\\System32\\OpenSSH\\ssh.exe', '-p', '1018', '-i', u'c:\\Users\\Russ\\.ssh\\id_rsa', '-o', 'StrictHostKeyChecking=no', 'localhost', 'uname', '-sm']
Check the Network > SSH Executable preference

But when I " ".join() that command line in a normal cmd.exe shell it works perfectly fine, retrieving the os type as requested:

C:\Users\Russ>C:\Windows\System32\OpenSSH\ssh.exe -p 1018 -i c:\Users\Russ\.ssh\id_rsa -o StrictHostKeyChecking=no localhost uname -sm
Linux x86_64



On Tue, Jun 5, 2018 at 10:00 AM, Russell Warren <[hidden email]> wrote:
Aha... missed this in your docs:

If Wing cannot find ssh or plink.exe you will need to add its directory to your PATH or set the Network > SSH Executable preference in Wing to the full path of the command. If this is set, Wing also tries to find scp (or pscp.exe on Windows with PuTTY) in the same directory as the specified executable.

I'll try that.


On Tue, Jun 5, 2018 at 9:56 AM, Russell Warren <[hidden email]> wrote:
Is there some way to select what ssh client Wing uses? Docs seem to say it will be either plink or ssh, but I don't see how to select it.

I can't get Wing working remotely (to my local).  This works 100% perfectly from Windows cmd.exe:

ssh localhost -i c:\Users\Russ\.ssh\id_rsa -p 1018

But this Wing setup gives me an error (with hostname as localhost):



This is the error I get:

The remote agent could not be installed on host id WSL local. Could not determine OS type (err=1).

PuTTY is prompting for a login name. Please add username@ to your Host Name in the remote host configuration. Or, you can create a saved session for your host in putty.exe, set the Connection > Data > Auto-login username, and then save the session.

Output received:

Unable to use key file "c:\Users\Russ\.ssh\id_rsa" (OpenSSH SSH-2 private key (old PEM format)) 
login as: FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey) 

I don't even have PuTTY installed, and I don't see a private copy inside Wing anywhere, so this seems like a buggy message?

Also confusing is that prior combinations (that I can't restore right now for some reason) have made it seem like Wing was using plink.exe. Wing even gave me an explicit plink.exe command to try to replicate to get past the authorized keys thing, but I don't have plink.exe on my path anywhere, so no dice.  I did end up searching my machine for it there's a copy of plink.exe tucked away somewhere that Wing was using, but all I could find was some plink.exe instances in my X server dirs (Xming and VcXsrv), but it seems unlikely to me that Wing located those ones. I see no captive copy, either.

Any help here is much appreciated!  Ideally I'd just tell wing to use the ssh that comes with my Windows (at C:\Windows\System32\OpenSSH\ssh.exe), but that is a fairly recent development so maybe I'm being optimistic?

Thanks,
Russ


On Thu, May 31, 2018 at 8:44 AM, Wingware Support <[hidden email]> wrote:
Russell Warren via wingide-users wrote:
    You might need to treat WSL as a different machine and use
    wingdbstub and external launching like with cygwin.  There a howto
    for cygwin at https://wingware.com/doc/howtos/cygwin


Hopefully not... I glaze over a bit when looking at that method. :)  I
kind of hoped that it would just work if I could specify the python exe
inside WSL.  Thinking (likely oversimplified) was that Wing-on-Windows
is just a great IDE run by your captive python, and all project/code
python stuff would be handled by the executable specified in the project
properties.  Not sure how clean that separation is, though.  The
aforementioned wslpath conversions seem like they are probably essential
to provide to the project's python executable.

I don't think there's much hope for running wsl's python directly without the complexity of something like the cygwin instructions, although configuration could possibly be automated.

I think it would be simpler to set up ssh into WSL and then use the new remote development support described at http://wingware.com/blog/remote-development and documented in more detail at http://wingware.com/doc/proj/remote-hosts

I've put adding a How-To and support for WSL on our list of things to look at in the near(ish) term.


Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com




--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.



--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.



--
Russell Warren
Perspexis Technologies Inc.

This information is confidential and intended solely for the use of the individual or entity to whom it is addressed.
If you have received this email in error, please notify the sender immediately.

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
Russell Warren wrote:

> Some progress, but now a different error I can't figure out.  Setting
> the ssh excutable to my local ssh.exe yields this error:
>
>     The remote agent could not be installed on host id WSL local. Could
>     not determine OS type (err=None).
>
>     Output received:
>
>     Failed to start command line:
>     ['C:\\Windows\\System32\\OpenSSH\\ssh.exe', '-p', '1018', '-i',
>     u'c:\\Users\\Russ\\.ssh\\id_rsa', '-o', 'StrictHostKeyChecking=no',
>     'localhost', 'uname', '-sm']
>     Check the Network > SSH Executable preference
>
>
> But when I " ".join() that command line in a normal cmd.exe shell it
> works perfectly fine, retrieving the os type as requested:
>
> C:\Users\Russ>C:\Windows\System32\OpenSSH\ssh.exe -p 1018 -i
> c:\Users\Russ\.ssh\id_rsa -o StrictHostKeyChecking=no localhost uname -sm
> Linux x86_64

That does look like it should work.  It seems like Wing should get the
output and it's valid.  I'm hoping to try WSL here soon to see if I can
replicate this.

A possible work-around is to install the remote agent manually instead,
as described here:  http://wingware.com/doc/proj/manual-remote-install

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Using Wing on Windows with python from a backing WSL

WingIDE - User mailing list
In reply to this post by WingIDE - User mailing list
Russell Warren via wingide-users wrote:
> Has anybody tried using Wing on Windows, but having the python
> executable using a python that resides inside the WSL (Windows
> Subsystem for Linux)?

Sorry for the delay.  I finally managed to try WSL on Windows 10 and I
got it working to Ubuntu under WSL, using Wing 6.0.12 and the remote
development feature as described in my notes below.  The key thing
needed is to set up the remote host configuration so that the Host Name
does not contain '@' (as in username@127.0.0.1).  Wing has a bug that
does the wrong thing in this case.  Instead, just use 127.0.0.1 and set
up the remote user name to use in a PuTTY saved session or with OpenSSH
configuration, as described below.

I tested this on a system with PuTTY already on it, so I used that for
my notes, but this can also work with OpenSSH.  If you don't have WSL
set up already, you'll need to search online for more detailed
instructions for that part:

* Enable WSL in Windows 10
* Install Ubuntu from the Windows store
* On Ubuntu:  apt-get install python3
* Set up ~/.ssh/authorized_keys on Ubuntu for the ssh key I'm using
* If you already have an ssh server running somewhere on your system on
port 22 you will need to change
   the port number used on Ubuntu in /etc/ssh/ssh_config and then do
'sudo service ssh --full-restart';
   this wasn't needed in my case, however.
* Start pageant from Windows and right click on the icon that appears in
lower right of Windows to load
   your private key into Pageant
* Start PuTTY from Windows and type 127.0.0.1 into Host name field on
the first page, and then go to the
   Connection > Data page and fill in the user name for Ubuntu into the
Auto-login username
   field.  Then go back to the first page (Session) in PuTTY and press
Save so it saves the session.
   After this, plink/etc use that configuration when connecting to
127.0.0.1.
* Verify "plink 127.0.0.1" on Windows connects to Ubuntu without
prompting for user name or password
* Use New Project and specify Connect to Remote Host (via SSH) as
project type and enter:
     Identifier:  wsl
     Host Name:  127.0.0.1
     Python Executable:  python3
   I recommend *not* checking "Store Project File on Remote Host" for
your initial testing.
* Set up the project as usual with Add Existing Directory/etc and save it.

If you're not using PuTTY then you would add something like this to your
OpenSSH config file:

Host 127.0.0.1:
     User username

Note that I have not yet tried this with the OpenSSH that now can be
enabled in Windows 10 (see
https://blogs.msdn.microsoft.com/commandline/2018/01/22/openssh-in-windows-10/ 
).  I  think there may be separate issues with that, and that's next on
my list.  Don't enable this if you haven't already because it may
complicate setup, among other things requiring moving the Ubuntu ssh
server port number off port 22.

I also did one questionable thing based on the vast amount of
misinformation out there.  I include this in case it actually did something:

* sudo apt-get purge ssh-server
* sudo apt-get install ssh-server
* sudo service ssh --full-restart

We plan to fix the bug that prevents username@127.0.0.1 from working in
the remote host configuration, although probably not until 6.0.13 since
it requires introducing a new minor feature.  After that, configuration
for WSL should become essentially the same as for any other remote host
or container.

See http://wingware.com/doc/proj/remote-hosts for details on remote
development in general.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide