I would like to debug a Twisted Application (10.0.0) using the Eclipse (3.5.2) PyDev Module (1.6.4) and Python (2.6.5). To run the application from the command line I would specify the following:
c:\python26\python c:\python26\scripts\twistd.py -ny mytwistedapp.py
To accomplish this using PyDev I created a new PyDev project and imported mytwistedapp.py and twistd.py. Under the project's run configuration I specified c:\python26\scripts\twistd.py as the main module. If I select Run -> Debug Configurations it runs twistd.py with no parameters (half-way there, right?). If I try to add the program arguments to the run configuration (-ny mytwistedapp.py) they are processed by the PyDev debugger instead of twistd.py. Two questions:
- Is specifying twistd.py as the main module the right approach?
- If so, how can I pass twistd.py the parameters it needs to run mytwistedapp.py (-ny mytwistedapp.py)?
First off, thank you all so much for your kind and gracious support in this matter!
The key to running a twisted application via the PyDev module of Eclipse is to define twistd.py as the Main Module in the Run Configuration. The following steps can be used:
These instructions assume you can already run twisted applications on your system, which means you've installed zope and twisted. For example, the following already works for you:
These instructions also assume that you have already installed and configured PyDev in Eclipse, including the definition of the PYTHONPATH. 1. Navigate to Window -> Preferences -> PyDev -> Interpreter (Python) 2. Under Libraries Tab (System PYTHONPATH), System Libs should already contain location of your Python instllation (e.g., c:\python26, c:\python26\dlls\, c:\python26\lib, etc). 3. Add the Zope egg and the Twisted folder to System libs. For example, c:\python26\lib\site-packages\twisted and c:\python26\lib\site-packages\zope.interfaces-3.6.1-py2.6-win32.egg
Create a new Pydev project
Now that your project is setup, create a new Run Configuration.
And that's it! The key is importing twistd.py as the Main Module, which then allows the program arguments to be passed into twsttd.py, just as you would do from the command line.