If you were wondering which is a good IDE for Python Development, there are a lot of them. My personal favorite is the Eclipse but I also use the default IDLE Python at times. This post is a guide on Installing and setting up Eclipse and PyDev in a Windows PC.
Step 1: Install Python
You can find a guide on Installing Python in your system here.
Step 2: Install Eclipse
You can download the “Eclipse Classic” version (32-bit or 64-bit) from http://www.eclipse.org/downloads/ (~ 184 Mb).
The downloaded file wil be a zip file. Simply extract it to any desired location, For example, extract it to your C: drive. So, now your eclipse folder will be “C:\eclipse”.
To open up eclipse, go to your eclipse installation folder (It is “C:\eclipse” in mine) & open “eclipse.exe” .
You would see the welcome splash screen and then , you would be prompted to “Select a workspace” . You can choose any location you want or just leave it to the default values.This will the location where your projects and source codes will be saved.
Now, you will see the Eclipse Start Page. You click on the “x” marked in red to close it and go to to the Workplace.
Step 3: Install PyDev
In your Eclipse program, you need to check for updates. You can do so by clicking on the Help>Check For Updates from the toolbar.
After checking updates, install them if prompted. Then Click on Help>Install New Software.
Now, you will be presented with a screen as shown below. Click on “Add“.
Now , put Name field as “PyDev” and “http://pydev.org/updates” as the Location and press “OK“.
Now, wait for a few seconds while it processes it. Now, tick on PyDev as shown below and click “Next“.
Now, “Accept” the license agreement and click “Finish“. It would start downloading the necessary files and install PyDev. You will be prompted with a message box asking whether you Trust Certificates.,simply select them and press “OK“.
After the installation is complete,it will prompt you to restart Eclipse. So, you have now successfully installed PyDev in Eclipse.
Step 3: Configure Interpreter
Click on Window>Preferences
Now click on “PyDev” to expand section and click on “Interpreter – Python“. Now, click on “Add“.
Now, add the Interpreter Name as “Python27” and “Interpreter Executable” as “C:\Python27\python.exe” . You can change the location if you installed python in another directory. Then press “OK“.
You will be prompted to make a selection of which folders to be added to the SYSTEM pythonpath. Simply, choose “Select All” and press “OK“.
Now, finally, you will have your preference windows similar to the one shown below:
Now, you have done configuring the Interpreter. Now, lets see how we can start coding python in Eclipse.
Step 4: Creating a sample Python project in Eclipse
To start a Python Project in Eclipse, Go to File>New>Project.
Now, select the Wizard as “PyDev Project” and click on “Next“.
Now, Put the Project Name as “Hello World” or anything you want. And select the option “Create ‘src’ folder and add it to PYTHONPATH“. And press on “Finish“. (You might be prompted if you want to open it with PyDev perspective, click Yes).
Now, click on the small triangle indicated next to your “Project Name” to expand it. Now, left click on “src” and select “PyDev Module“.
Now, choose any name (which is going to be the name of your python source file) and input it in the “Name” field and press “Finish”. Make sure that you DO NOT ADD the .py extension, you only need to add a name.
You may have to double click on the helloworld.py (or what you named it) to open the source code file.
Add the following line to the source code:
print “Hello World”
Save the file, by pressing CTRL+S or File>Save.
To run your python code, click on the button which looks like a small Green Play button, and Go to Run As>Python Run.
The output of your program will mostly be displayed in the lower portion of the Eclipse window as shown below.
So, yeah you installed Eclipse, installed and configured PyDev and got a little familiar with writing python code and executing them in Eclipse. Thats all for today.
If you liked/disliked or have any sort of questions, please leave a comment. And yeah, you can always follow my blog to get future updates. 😀