Thursday, November 27, 2014

How to install the Pydev on Eclipse, to do Python coding?!

Today I had to do some programming with Python. As many of you may know, Python has a very simple command line itself and for complecated programming it is difficult to handle errors and write codes quickly. I had a quick search to see what IDE exists for Python. I discovered that my popular IDE 'Eclipse' also has a plugin for Python. I am using Eclipse for Java. So, it was very good to use it for Python as well. Because I am familiar with its environment.

I assumed that you have Eclipse and Python on your computer. However, if you do not have. you can download them here:
Python: https://www.python.org/downloads/
Eclipse : https://eclipse.org/downloads/

However, installing the Pydev-Python plugin' was a little tricky. So, I decided to share with you.

First of all, you need to add Pydev to the eclipse. My IDE is Eclipse Juno.

1- go to help->install new software
2- Press the Add button and in the url field write: http://pydev.org/updates and press Ok



3- The tricky part is that if you are using old Eclipse such as Juno, you cannot use the latest Pydev. Even if you install it, you cannot use it and see it in the eclipse. The version that is good was for Juno was 2.8.2. So, the PyDev in the bellow window and select the proper version. Another thing that you should notice is the if you do not deactivate the "show only the latest versions of available software", you cannot see the old versions such as 2.8.2.















4-If you have installed the newer version accidentally and you cannot see the Pydev in the new project section. The Eclipse does not permit you to re-install another Pydev. So, first you should delete Pydeve and the install another version. For, deleting follow these steps: Go to help->about eclipse, below the pop-up window, press the installation detail, select the Pydev and uninstall it.


5- Now almost you have done. However, you should connect your Python with Eclipse. In this order, click on windows->preferences->expand Pydev->Interpreter-Python. Add new and click brows in the pop-up windows and show the Python.exe. Eclipse will find the required files and Dlls.

 

6- Congratulation, now you can create your first Python code in Eclipse. File->New->Project->create Python. Press next choose a meaningful name for your project and Finish.



7. make a Python package by right click on the project name->new->Pydev package. Select a name for the package and click OK. When the package create automatically a Python file with name of "__init__" will create.

8. Now make a new module by right click on the package->new->Pydev Module. Select a meaningful name for it. and press Finish.A pop-up window come up that ask do you want to use any template or just an empty file. Just now select an Empty and OK.



9. Start coding and enjoy the power of Eclipse ;) and press F9 for execution.

10. Another tricky problem that I love the interactive console of Python. Eclipse gives this power to you to have it there beside your code. Just click Ctrl+Alt+Enter to show up the console. However, I got this strange error in the interactive console of Pydev:

Error initializing console. Unexpected error connecting to console. Failed to receive suitable Hello response from pydev console. Last msg received: HTTP server returned unexpected status: null

The reason of this problem is quite strange but it has a simple answer. It seems that you have defined a proxy for your Internet Explorer. Open the IE->Internet Options->connections tab->Lan Settings->Advanced and just add the Localhost;127.0.0.1 in the exception window.