2

I upgraded eclipse from 3.6 to 4.2 and Aptana from 2 to 3 with pydev

Now I cannot get the debugger to work. I get the following errors:


Traceback (most recent call last):
File "C:\Google\eclipse\plugins\org.python.pydev_2.6.0.2012062121\pysrc\pydevd.py", line 4, in <module>
from pydevd_comm import  CMD_CHANGE_VARIABLE, \
File "C:\Google\eclipse\plugins\org.python.pydev_2.6.0.2012062121\pysrc\pydevd_comm.py", line 78, in <module>
import pydevd_console
File "C:\Google\eclipse\plugins\org.python.pydev_2.6.0.2012062121\pysrc\pydevd_console.py", line 3, in <module>
from code import InteractiveConsole
ImportError: cannot import name InteractiveConsole

!ENTRY org.python.pydev.debug 4 4 2012-07-08 22:09:17.635  
!MESSAGE Unexpected error setting up the debugger  
!STACK 0  
java.net.SocketException: Socket operation on nonsocket: configureBlocking  

_at java.net.DualStackPlainSocketImpl.configureBlocking(Native Method)  

_at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)  

_at java.net.AbstractPlainSocketImpl.accept(Unknown Source)  

_at java.net.PlainSocketImpl.accept(Unknown Source)  

_at java.net.ServerSocket.implAccept(Unknown Source)  

_at java.net.ServerSocket.accept(Unknown Source)  

_at org.python.pydev.debug.model.remote.ListenConnector.run(ListenConnector.java:57)  

_at java.lang.Thread.run(Unknown Source)
Avery
  • 2,270
  • 4
  • 33
  • 35
Brian
  • 127
  • 2
  • 10

2 Answers2

2

If you're encountering this error, check to make sure you don't have any other code.py modules in your PYTHONPATH - ie, in your project. For example I was using web.py and the tutorial has you create a code.py file - renaming this to main.py, the debugger was able to import InteractiveConsole from the correct module (the one in python27\lib).

Adam S
  • 16,144
  • 6
  • 54
  • 81
1

I think that the problem is that the import:

from code import InteractiveConsole 

is giving an ImportError. Check if the 'code' module is in your PYTHONPATH (should be at the Python lib: Python/lib/code.py)

I.e.: Open a shell in the command line:

[07:55:55 X:\]python
Python 2.7.2 (default, Feb 23 2012, 00:24:32) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> code.__file__
'c:\\bin\\python-2.7.2\\lib\\code.pyc'

If it's really not there, it's a problem in your Python install (should definitely be there).

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • Fabio, Thanks for the reply. Tried all your suggestions and everything seems ok, i played with the PYTHONPATH, re-install Python 2.7, everything else is working I can run the applications without any issues, but the Debugger is STILL getting the same error – Brian Jul 09 '12 at 14:59
  • Can you do a try..except in "import pydevd_console" (on pydevd_comm.py) and see if it works then? – Fabio Zadrozny Jul 09 '12 at 16:05
  • Fabio, Yes, that did work! the try..except on "import pydevd_console", I can't thank you enough, I was pulling my hair out. Thank you again. – Brian Jul 09 '12 at 20:12
  • Still, that seems really weird... can you do the try..except and do a print('\n'.join(sorted(sys.path))) to see how's your PYTHONPATH at that stage? It's really strange that it doesn't find the 'code' module (it should be there on Python 2 or 3). – Fabio Zadrozny Jul 10 '12 at 11:42
  • Output: C:\eclipse\plugins\org.python.pydev_2.6.0.2012062121\pysrc C:\python27 C:\python27\DLLs C:\python27\lib C:\python27\lib\lib-tk C:\python27\lib\plat-win C:\python27\lib\site-packages C:\python27\lib\site-packages\PIL C:\Windows\system32\python27.zip C:\workspace4\ws2\src – Brian Jul 10 '12 at 19:00
  • And do you have a 'code.py' there (under "C:\python27\lib") which has an InteractiveConsole class? – Fabio Zadrozny Jul 11 '12 at 13:42
  • 2
    Humm... it's complaining that it does not find the InteractiveConsole class... Can you do: import code;print(code) at that try..except? My guess is that you have some other module with the name 'code' which is overriding the default 'code' from the standard library. – Fabio Zadrozny Jul 11 '12 at 14:04
  • Thank you, Fabio, Adam I looked at this problem again and found a directory that was named "Code" that was creating this issue. Thank you again. – Brian Apr 03 '13 at 17:33