Cam
Cam

Reputation: 15234

How do I add a breakpoint in eclipse using pydev?

I would like to add a breakpoint to a pydev project. I am using eclipse with the pydev plugin. I am running Windows 7. The file I want to debug is located at C:\cygwin\workspace\project\main.py .

When I attempt to add the breakpoint by double-clicking to the left of the line on which I want the breakpoint, the breakpoint appears to be visually present in the file, but then I get this error when I click debug:

pydev debugger: warning: trying to add breakpoint to file that does not exist: /workspace/project/C:\cygwin\workspace\project\main.py

Note that the file still appears to run fine both in debug and normal run modes. I can also run the file outside the ide by running python main.py.

Upvotes: 3

Views: 3838

Answers (3)

Karthik
Karthik

Reputation: 111

pydev debugger: warning: trying to add breakpoint to file that does not exist: /vagrant/pytest/C:\Program Files\Git\vagrant\vagrant\pytest\remote.py (will have no effect)

The above error is keeping on occuring to me. I am using eclipse with pydev installed.

INitiualy I configured the PATHS_FROM_ECLIPSE_TO_PYTHON value wrongly but then updated it. But the updated value is not reflecting in the above error but shows old value only.

How to flush the old configurtion PATHS_FROM_ECLIPSE_TO_PYTHON and make the latest value used when executing the file

Upvotes: 0

Bryce Drennan
Bryce Drennan

Reputation: 709

I was actually able to get this working. I realize I'm using PyCharm, but the solution should be easily adapted since they both use PyDev. The basic problem is that the IDE is expecting windows paths while PyDev is expecting cygwin paths. I found the appropriate places in PyDev to do those conversions.

Here's my setup

  • configure your project to use a python for cygwin binary (this may not be necessary)
  • edit Program Files/JetBrains/PyCharm 2.5/helpers/pydev/pydevd.py. This converts the paths sent to the debugger to cygwin paths. Around line 597, where file = NormFileToServer(file) is located, make the following changes

                orig_file = file
                file = NormFileToServer(file)
    
                if not os.path.exists(file):
    
                    file = orig_file.replace('c:/cygwin','')
                    file = file.replace('\\','/')
                    file = file.replace(' ','\ ')
                    file = NormFileToServer(file)
    
                    if not os.path.exists(file):
                        sys.stderr.write('pydev debugger: warning: trying to add breakpoint'\
                            ' to file that does not exist: %s (will have no effect)\n' % (file,))
                        sys.stderr.flush()
    

    do the same filename conversion a few lines later under the elif cmd_id == CMD_REMOVE_BREAK statement

  • edit Program Files/JetBrains/PyCharm 2.5/helpers/pydev/pydevd_comm.py. This converts paths sent back to pycharm into windows paths. Around line 549 alter the code to look like this:

                myFile = pydevd_file_utils.NormFileToClient(curFrame.f_code.co_filename)
                myFile = "C:\cygwin" + myFile
                myFile = myFile.replace('/','\\')
    

Adjust the paths as needed. The big thing that helped me figure this out was to add PYCHARM_DEBUG=True in the environment variables of the PyCharm run/debug configurations.

Hope this saves someone else the 6 hours I spent figuring this out!

Upvotes: 4

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

Cygwin is not really properly supported in PyDev, thus, you either must work on windows using a python windows distribution or you must work on Linux using a python for linux...

The real issue is that the paths must be translated back and forth at each step when inside cygwin (to make the communication with the IDE)... some initial work has been done on that front, but it didn't go forward...

One approach I didn't really attempt but which could work could be trying to use all within cygwin (i.e.: use PyDev running inside cygwin too: the linux version of java/eclipse/pydev -- not only the python interpreter, that way both would see paths in the same way), but I haven't really tested that setup, so, I'm not 100% certain it'll work.

Upvotes: 1

Related Questions