Wing is a Python IDE that can be used to develop, test and debug Microsoft Excel add-ins written in Python with PyXLL. Two versions of Wing are appropriate for use with this document: Wing Pro is the full-featured Python IDE for professional developers, and Wing Personal is a free alternative with reduced feature set. 1.3 Installing Python on Mac OS X. 1.4 Installing Wing IDE 101 on Windows. Wingware.com web site. Find the Download link at the top of the web page and select Wing IDE 101 to download the installation package. Be sure to pick Wing IDE 101 to download if you don't want to pay for a license. If you are installing on a Mac, pick the Mac. Installation of the Wing IDE 101 Package The Python package from python.org contains an IDE (IDLE). This IDE works and it is simple to run, but it is prone to crashing. A better IDE is Wing IDE 101. This is a free package specifically for introductory programming classes.
Using Wing with Docker
Wing IDE is an IDE designed specifically for the Python programming language. Wing IDE is offered in a paid Pro version and in free Personal and 101 versions. To set up your Wing IDE installation to use Anaconda: Navigate to the Python configuration window: In Wing 101, in the Edit menu, select Configure Python. Wing Pro is a Python IDE that can be used to develop, test, and debug Python code running on Docker containers. This document describes how to configure Wing Pro for Docker. To get started using Wing Pro as your Python IDE, please refer to the tutorial in Wing's Help menu or read the Quickstart Guide.
Index of All Documentation » How-Tos » How-Tos for Containers »
Wing Pro is a Python IDE that can be used to develop, test, anddebug Python code running on Docker containers.
This document describes how to configure Wing Pro for Docker. To get started using WingPro as your Python IDE, please refer to the tutorial in Wing's Help menu or read theQuickstart Guide.
Getting Started
Before you can work with Docker you will need to download and install it.
On Windows and macOS, downloading Docker Desktop from the Docker website is the easiest way to install it. Be sure to launchthe Docker Desktop after you install it, so the daemon is started.
On most Linux distributions, Docker CE (the free community edition) can be installedwith the docker-engine package as described here.
You should also install Wing Pro if youdon't already have it.
Create a Working Example
This guide uses a small real world example to illustrate the necessary configuration steps.If you want to try out the configuration without altering your existing Docker containers,start by creating a directory docker and placing the following files into it.
Dockerfile:
app.py:
Then build the Docker container by typing the following in the docker directory:
You can now run your container like this:
You will need to substitute /path/to/docker with the path to the docker directoryyou created above; the quotes make it work if the path has spaces in it.
You can now try this tiny Flask- web app by pointing a browser running on your host systemat it:
If you are using Docker Desktop, then use http://localhost:4000/
If you are using Docker CE, you will need to determine the IP address of yourcontainer and use that instead of localhost. One way to do this is to type dockerps to find the Container ID for your container and then use it in the following in placeof c052478b0f8a:
Notice that if you make a change to app.py in Wing, then the change will be reflectedin your browser when you reload the page. This is due to using both the -v argumentfor dockerrun to mount a volume in the container, and the fact that app.run() forFlask is being passed use_reloader=True.
Working with Docker through Local Files
In most cases you will want to use Wing with the local (host-side) copy of files that aremapped into the container, with some additional configuration so that processes running onthe container can be debugged.
(1) Map host files to the container
As in the above example, you will need to make local (host-side) files available in thecontainer, either at build time or by mapping a volume into the container at runtime.
This can be done at build time in the Dockerfile with COPY. If you use this form,you will need to stop, rebuild, and restart your container every time you make a change:
Alternatively, you can map the directories at runtime, which allows you to keep workingwith changed files without restarting the container (although this also depends on theability of the hosted app to reload your changes):
Both of these also work on Linux and macOS, with the appropriate paths substituted.
(2) Install the debugger
To access Wing's debugger on the container, add another -v mapping to your dockerrun command line, so the Wing installation on the host is made available to thecontainer. For example on Windows:
Or on Linux:
Or for macOS:
You will need to substitute the correct installation location for Wing on your host, whichcan be seen in Wing's About box, and the full path to the docker directory youcreated earlier.
Mapping the Wing installation across OSes (for example from Windows host to Linuxcontainer) works because Wing's installation has all the files necessary files fordebugging on every supported OS.
(2) Copy and configure wingdbstub.py
Debugging is initiated on the Docker side by importing Wing's wingdbstub module. Touse this, copy wingdbstub.py from your Wing installation to your mapped directory onthe host. For example on a Windows host:
Or on a Linux host:
Or a macOS host:
After copying, you will need to edit the file to change kWingHostPost fromlocalhost:50005 to a value that uses the IP address or name of the host computer, forexample if your host's IP address is 192.168.1.50:
![Install Wing Ide Python Install Wing Ide Python](https://websiteforstudents.com/wp-content/uploads/2019/06/wing_python_ubuntu_install_3.png)
Best Python Ide
With Docker version 18.03 or later you on Windows or macOS, you can use the special namehost.docker.internal instead of the IP address (this does not work on Linux):
You will also need to set WINGHOME to the location where you have mapped your Winginstallation on the container:
(3) Enable access
Before Wing will accept any debug connections initiated from outside of the IDE, you needto click on the bug icon in the lower left of Wing's window and enabling AcceptDebugConnections.
Then copy the file wingdebugpw from the SettingsDirectory shown in Wing's Aboutbox into the same directory as wingdbstub.py. This is the security token that Winguses to authenticate the debug connection. Copying this file into place manually isrequired because the debugger cannot write a persistent security token in most Dockerconfigurations.
(4) Establish a file mapping
In order for Wing's debugger to be able to find files running in the container on thehosts's file system, you must tell Wing about the relationship between the directories youmapped from the host to the container with COPY or the -v option for dockerrun.
The easiest way to do this is to be sure that you add all your source directories to yourproject in Wing. This allows Wing to discover all the files that will be used on Dockerand to build a mapping between the location of the files on the two systems. SeeLocation Maps for details.
Manually specifying a file mapping
In rare cases where you need to establish a file mapping by hand as described in ManuallyConfigured File Location Maps, you will need todetermine the IP address to use in the mapping.
For Docker Desktop, the IP address to use is the one for the host system. This isbecause Docker Desktop configures networking in a way that makes the container's IPaddress appear to be the same as the host's.
For Docker CE, you can obtain the container's IP address by determining the containerid with dockerps and then use it to inspect the container as in the following examplefor container id c052478b0f8a:
(5) Initiate debug
Once these steps are complete, you can initiate debug from Python code running in thecontainer by importing the module wingdbstub.py as follows:
Your copy of wingdbstub.py must be in the same directory as the source code thatimports it, or somewhere on the PYTHONPATH (aka sys.path).
The first time you try to debug, Wing will reject the debug connection and prompt you toaccept the debug security token being used in the container. After accepting the token,future debug connections will be accepted.
Prefedit 4 3 16. To preauthorize the debug connection, you can copy the file wingdebugpw from theSettings Directory on the host into the same directoryas wingdbstub.py on the container.
Once you successfully start debugging and the IDE accepts the connection, the bug icon inthe lower left of Wing's Window turns green and the toolbar changes to its debugconfiguration. The debug process keeps running until it reaches any exceptions orbreakpoints.
If you are using the small auto-reloading Flask container example from Create a WorkingExample above, you can add importwingdbstub as the first line of app.py. When yousave the file, Flask should auto-reload it, which will initiate debug. You can set abreakpoint by clicking in the leftmost margin to the left of the return statement inapp.py and then trigger it by reloading the page in your browser.
To learn more about Wing's debugger, take a look at the Tutorial in Wing's Help menuor the DebuggingCode section of the Quick Start Guide.
Trouble-shooting
Wing Ide 101
If your configuration does not work, try setting kLogFile in your copy ofwingdbstub.py to see whether the debugger is reporting errors. Also, looking at theend of ide.log in the SettingsDirectory listed in Wing's About box may revealwhy a connection is failing, if it is being refused by the IDE.
Setting kExitOnFailure in your copy of wingdbstub.py is another way to seewhy debug or the connection to the IDE is failing. In this case, when you restartthe container it will fail to start and print a message indicating the errorencountered during importwingdbstub.
If the debug connection is established but breakpoints are not reached, you may need toadd your source directories to the project in Wing so a mapping can be established tothe location of files on Docker. One way to diagnose this is to add assert0 to yourcode. Wing will always stop on that and will report the file it thinks it should beopening in the Exceptions tool. Those can be used to manually configure a filelocation map, as described above.
Remote Development to Docker with SSH
Docker CE (but not Docker Desktop) is sometimes used to host a more complete installationof Linux, acting more like a stand-alone system that includes the ability to ssh fromthe host system into the container. In this case, Wing Pro's Remote Development capability can be used instead, to work directly with files andprocesses running under Docker.
For more information, see Remote Python Development(if the debug process can be launched from the IDE) or Remote Web Development (if the debug process is launched from outside of theIDE).
Related Documents
For more information see:
- Docker home page provides downloads and documentation.
- Quickstart Guide contains additional basic informationabout getting started with Wing Pro.
- Tutorial provides a gentler introduction to Wing Pro's features.
- Wing Pro Reference Manual documents Wing Pro in detail.