• Decrease font size
  • Reset font size to default
  • Increase font size

Who's Online

We have 40 guests online

PayPal Donation

PyDev with Eclipse and Aptana code completion freezes

I ran in to a strange issue the other day while installing Eclipse + PyDev for python development with the django web framework on a linux machine. This system was using OpenSuse 12.1, Eclipse Indigo, and PyDev 2.5. Everything installed quick as a snap and I was off running until I started typing my first few lines of code... then... it froze on me, as I typed "os." After reviewing the error I saw the command completion utilities for PyDev was failing to bind to the 'localhost' on port 8000.

Note: The same issue will occur with Aptana Studio and the Eclipse Aptana Studio Plugin.

Screenshots of the error "Error connecting to python process":

PyDev command complete exception

How to Fix...

1) First Exit Eclipse

2) I checked netstat to see if the port was already in use:

>netstat -a | grep 8000

Nope not in use, found nothing bound to port 8000

3) I then I checked /etc/hosts and found that 127.0.0.1 was not being mapped to 'localhost'

>sudo vim /etc/hosts
    # IP-Address  Full-Qualified-Hostname  Short-Hostname
    #
    127.0.0.1       localhost

4) Finally I restarted the network

>sudo /sbin/rcnetwork restart

Bingo!! Eclipse and Pydev were happy as can be and command completion was working like a charm

An Alternitive route...

If you do not want to change your /etc/host file to include mapping of 127.0.0.1 to 'localhost' then you can modify the PyDev source. Keep in mind though if you upgrade PyDev you will most like have to modify it again.

1) First exit Eclipse 2) From your eclipse root directory

>grep -r "\"localhost\"" *
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000), MathHandler)
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/smtplib.py:  >>> s=smtplib.SMTP("localhost")
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/smtplib.py:         >>> s=smtplib.SMTP("localhost")
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/urllib.py:           "localhost", "thishost", "ftperrors", "basejoin", "unwrap",
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/imaplib.py:    PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "localhost"))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/pydev_localhost.py:            for addr_info in socket.getaddrinfo("localhost", 80, 0, 0, socket.SOL_TCP):
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = MathServer(("localhost", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/pydev_localhost.py:            for addr_info in socket.getaddrinfo("localhost", 80, 0, 0, socket.SOL_TCP):
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("localhost", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = MathServer(("localhost", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("localhost", 8000))

3) Finally perform a search and replace of "localhost" to "127.0.0.1" ...Also, if port 8000 is being used by another app or service you can change that as well using the same syntax.

>perl -p -i -e 's/"localhost"/"127.0.0.1"/g' `grep -ril "\"localhost\"" *`
>grep -r "\"127.0.0.1\"" *
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000), MathHandler)
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/smtplib.py:  >>> s=smtplib.SMTP("127.0.0.1")
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/smtplib.py:         >>> s=smtplib.SMTP("127.0.0.1")
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/urllib.py:           "127.0.0.1", "thishost", "ftperrors", "basejoin", "unwrap",
plugins/org.python.pydev.jython_2.5.0.2012040618/Lib/imaplib.py:    PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "127.0.0.1"))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/pydev_localhost.py:            for addr_info in socket.getaddrinfo("127.0.0.1", 80, 0, 0, socket.SOL_TCP):
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:server = MathServer(("127.0.0.1", 8000))
plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc/_pydev_SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/pydev_localhost.py:            for addr_info in socket.getaddrinfo("127.0.0.1", 80, 0, 0, socket.SOL_TCP):
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = SimpleXMLRPCServer(("127.0.0.1", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:server = MathServer(("127.0.0.1", 8000))
plugins/org.python.pydev_2.5.0.2012040618/PySrc/_pydev_SimpleXMLRPCServer.py:    server = SimpleXMLRPCServer(("127.0.0.1", 8000))

Start up Elipse and Walla! command completion is working again.

Here are some other references to the same issue:

 
Copyright © 2000 to 2012 Linkapps.com All rights reserved.