How To Work With Python and Eclipse ? PyDev in action! - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Random Posts

How To Work With Python and Eclipse ? PyDev in action!

Share This

Are you just a beginner with Python? Then this tutorial is going to help you a lot.

In this tutorial, we are discussing how can you work with Python in Eclipse IDE through PyDev. After going through this tutorial, you will be able to run your first Hello World python program.

Assumptions

Eclipse is a popular IDE, mostly used for Java Development. But this Eclipse IDE can also be used effectively for Python development.

Here we assume that you already have Eclipse IDE with you and you are familiar with how to work with the eclipse at least for Java or C, or C++ programming.

In case you do not have Eclipse IDE with you, then you can install Eclipse from here.

Please make sure you are installing the right package with respect to your PC or Laptop configuration and architecture.

Another important point, you can just install Eclipse for the Java Developer option leaving any other options like Eclipse for EE Developers and all.

Download and Install Python

First, you need to visit the python website to download the latest version of Python. Here in this tutorial, we have used Python version 3.7.3

Once downloaded, please install the python with all default settings.

As the installation is complete, now you are ready to work with Python in Eclipse.

Next, let us discuss how to set up Eclipse IDE with PyDev, a plugin for Python Development.

Setting up PyDev in Eclipse

  • Open Eclipse IDE
  • Go to Help --->Eclipse Marketplace
  • In the Eclipse Marketplace. type "PyDev" in the "find" search placeholder, like following 

  • And then hit Enter.
  • Eclipse IDE will now search for the PyDev plugin and if the search is successful it will be ready to be installed. You will receive the prompt like following


  • Click on the Install button
  • The eclipse will now install the PyDev plugin and while installing it will prompt to confirm selected features. Just be happy with the default options and press Confirm button as follows
  • After you have confirmed the selected features, now Eclipse will place the "Eclipse Public Licenses" before you so that you can review and accept them. Accept it to proceed and press the Finish button like the following.

  • Once you click Finish, Eclipse will install PyDev from the internet to your machine and ultimately, EClipse will ask for your permission to restart the Eclipse IDE. We recommend to you restart the Eclipse IDE

After the Eclipse IDE restarts, you just be sure that from now on you can develop Python codes into Eclipse as now your Eclipse IDE is plugged in with PyDev. you can check by yourself that indeed, your Eclipse IDE has PyDev within it, by pressing Window ---> Preference in the Eclipse IDE.
You will get PyDev listed on the left-hand side in the Eclipse Preference view as shown below

  
So, you have successfully set up the PyDev plugin with Eclipse. Now it is your turn to write your first Python Code in Eclipse

Create A PyDev Project in Eclipse

  • Go to File ---> New ---> Project in Eclipse and expand the PyDev vertical tab as shown below
  • Now select the PyDev Project option from the list and click the "Next" button. You will receive a prompt like the following

  • Click on the link "Please configure an interpreter before proceeding" to configure the Python interpreter. After clicking on this link, just choose the option labeled with "Choose from list"
  • You will receive a prompt having some interpreter options listed and checked by default as shown below. Just accept all the default checking and press the "OK" button

  • Now Eclipse will revert you back to the Project Creation prompt and now you have to select a project name in the "Project Name" field.
  • You can give any name as per your wish, but for the time being, just to go along with us, type "FirstPyProject" in the Project Name field and click the "Finish" button like following


  • After a trivial prompting of opening a proper perspective, Eclipse will create "FirstPyProject" for you and you can check its existence in the Project Explorer Pane of Eclipse. 


Write & Execute HelloWorld Program

  • Right-click on the FirstPyProject in the Project Explorer Pane of Eclipse
  • Go to New ---> Source Folder
  • Provide a name to your source folder. You can provide any name, but just to go along with us, give a name "FirstPy", and hit Finish, just like below
  • Now if you expand the FirstPyProject in the Project Explorer pane, you can check if a folder with the name "FirstPy" is there.
  • Next, right-click on the source folder and go to New --->File to create your python source code
  • Give a name "helloworld.py" to this file, just like the following, and hit the Finish button

  • Expand the "FirstPy" source folder to check that the "helloworld.py" file is there.
  • Now, double click on the "helloworld.py" file so that it opens in the editor pane of Eclipse IDE.
  • Next, in the blank file "helloworld.py", you type in the following statement and save.

print("Hello World!")
  •  At this stage, you will have something like the following


  • Now run the program by right-clicking on the code and then by going Run As ---> Python Run
  • You will see the desired output "Hello  World!" printed in the console.
  • Congratulation! You have successfully written and executed your first python program in Eclipse IDE with PyDev. :)


We sincerely hope that this tutorial will boost your python learning experience. In case you are really curious to know how does a python program run indeed, you can check out this tutorial.


Happy Exploring!

No comments:

Post a Comment