Saturday, May 27, 2017

Develop a python program with PyDev for Eclipse

IDE (integrated development environmen) is essential nowadays to create a program. I will explain how to develop python programs with PyDev in this post.

At first, download and install Ecripse:
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/marsr




There are some kinds of Eclipse and I think any Eclipse is OK, but I downloaded Eclipse for Java EE developers because I would make web applications.

Install the Eclipse after downloading it, then open Eclipse. Click "Help" from then menu bar and click "install new software". (If you are asked if you will create a workplace, choose yes.)



Add "http://pydev.org/updates" in the "Work with" box and click "Add".


You will see a window like below will pop up. Write "PyDev" in the "Name" box and click OK.



Select "PyDev" and "PyDev Mylyn" then click next.

Then you can install them to Eclipse.


After installing them, click "open perspective" from upper right.


Choose "PyDev" and click OK.


PyDev perspective is shown now.

Click "Window" from the menu and click "Preferences".


"PyDev" --> "Interpreters" --> "Python Interpreter"
Then click "New" and add your python.exe as the interpreter.


Python.exe should be somewhere like here.


Hello World


Enable PyDev window from upper right of Eclipse. Just click the Python mark to enable it:





Make a PyDev project named as "PyDev_test".
File-->New-->PyDev Project


Right click on the project name and choose "New" then "PyDev Module"

Name the module as "test" and click "Finish"


Choose "Module: Main" then "OK"

Change the program code as:
if __name__ == '__main__':
    print("hello world")

Then press CTRL + S. (Or simply save the file from the menu bar). Press the Run button from upper side of Eclipse. You will see "hello world" is displayed on the console.