Once you have installed Eclipse and PyDev, follow these directions to configure PyDev to run a shell and to correctly run programs that have console input
The basic PyDev install works great for developing purely graphical programs. But many programs prompt the user for “console” input using the
input
or
raw_input
functions. These instructions show how to configure PyDev for developing such console programs.
These instructions assume that you have already created a PyDev module, as described in the PyDev install instructions. You'll need that module to test your configuration.
One left-over oddity from the days of the MS-DOS operating system, is that Windows uses a different convention to indicate the end of lines of input. Unix, Linux, and Mac OS X use a single byte (with value 13) to indicate the end of a line. Windows uses two bytes (10 and 13). Somehow the combination of Eclipse, PyDev, Windows, and Python causes problems for programs that required console input. This step tells you how to avoid those problems. Based on an entry from the PyDev FAQ.
Select Program on the left, then press the New Launch Configuration icon above it to create a new launch configuration.
Select Run to start the shell. It should run in the console as shown below. If you get an error about the variable ${contain_loc} being undefined, that means you didn't have a Python module selected in the Project Explorer. Acknowledge the error, select a Python module, and try again.
exit()
in the shell, or click the red square (see figure), when you're done. Click the gray 'X' to close the shell history. If you don't want to enter
exit()
manually each time, you can add it to the end of your module code.
This step gives you a way to experiment with the functions and classes you have declared. It allows you to run a Python interpreter in the Eclipse Console view with the “working directory” configured correctly so you can easily import the module you are editing. The instructions are much like those above; the differences are highlighted.
Select Program on the left, then press the New Launch Configuration icon above it to create a new launch configuration.
Select Run to start the shell. It should run in the console as shown below. If you get an error about the variable ${container_loc} being undefined, that means you didn't have a Python module selected in the Project Explorer. Acknowledge the error, select a Python module, and try again.