First time here? Check out the FAQ!
1

Path is duplicated, can't debug

I've started a new topic for the discussion that was started around PyGTK (https://ask.wingware.com/question/8485/…). PyGTK is no longer in the picture... I'm just trying to get basic debugging working on a new installation of WingIDE 9.1.1.4.

I create a new project in a temp folder. I create the following file "test.py":

print("Hello world!")
x = 4 / 0
print("All done!")

I put a break point on the divide by zero line, and run the code. The break point does not catch, and the divide by zero gives me this error:

File "C:\Temp\Python\test/c:\Temp\Python\test\test.py", line 3, in <module>

builtins.ZeroDivisionError: division by zero

You can see that the path for test.py is messed up, sort of "doubled". I assume that's why the break points aren't working. And if I double-click on the error (what always used to take me to the offending line), it does nothing.

So what stupid, simple error am I making?!

UPDATE:

I've done a little more testing. In the New Project dialog, if I select "Use Existing Python" and under Python Executable select "Use Default" , everything works just fine, with break points and normal file paths. (That uses a Python 3.8.10 environment that I have installed on my system)

However, if as Python Executable I select "Command Line" (still under "Use Existing Python"), and I select my MSYS2 environment, "C:/msys64/mingw64/bin/python.exe", then I get this behavior of "doubled" path, and break points not working:

File "C:\Temp\Python\test4/c:\Temp\Python\test4\test4.py", line 4, in <module>

builtins.ZeroDivisionError: division by zero

The MSYS2 Python executable is 3.11.5, and seems to be working normally otherwise. But the WingIDE debugger doesn't seem to be "connected" into it somehow. Any suggestions?

JeffH's avatar
41
JeffH
asked 2023-09-19 20:34:36 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2023-09-30 01:52:49 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

Wing 9.1.2 fixes debugger support for mingw Windows python builds, which I think will address the problem. Please let us know if not.

Wingware Support's avatar
4.2k
Wingware Support
answered 2023-09-30 01:52:39 -0600
edit flag offensive 0 remove flag delete link

Comments

I have now tested Wing 9.1.2, and it does indeed seem to fix the problems I was having with debugging mingw python builds (in the MSYS2 environment) on Windows. Elsewhere in this thread it was pointed out that "MSYS2 is the only supported way to run PyGObject apps in Windows." So I'm very grateful to be able to get back to debugging my PyGObject (GTK3) project. Thank you for your prompt help in resolving this problem!

JeffH's avatar JeffH (2023-10-04 14:31:08 -0600) edit

Great, thanks for letting us know!

Wingware Support's avatar Wingware Support (2023-10-05 07:05:42 -0600) edit
add a comment see more comments
0

It looks like msys2's python is a Cygwin build of python so unfortunately it cannot be started from within Wing. You should be able to use it if you launch externally, though. Please see the Using Wing with Cygwin howto at https://wingware.com/doc/howtos/cygwin

Wingware Support's avatar
4.2k
Wingware Support
answered 2023-09-20 12:15:59 -0600
edit flag offensive 0 remove flag delete link

Comments

OK, I think I've made some progress. I copied my project files over to the MSYS2 environment, and can run the code there (with no debugging) from the MSYS2 command prompt. I copied wingdbstub.py from the install directory to the project directory. I created a new project and used Project > Add Existing Directory to connect the project to the source code in the MSYS2 environment. Then I added "import wingdbstub" to my code. Now when I run the code, I do get some reaction in Wing... I get the following in the status bar:

Debugger: Debug process running; pid=7024; Listening for connections: localhost (port 50005) …

But it still doesn't stop at breakpoints. And if I introduce an error to the code, it does catch the error in WingIDE, but I still get the same "doubled" path as before:

File "C:/msys64/home/jeff_/mytest/C:/msys64/home/jeff_/mytest/mytest.py", line 105, in <module>

builtins.ZeroDivisionError: division by zero ...
(more)
JeffH's avatar JeffH (2023-09-20 20:30:23 -0600) edit

I suspect you need to remove the *.pyc/pyo files or the __pycache__ directory which contains those. The files were probably generated earlier with the invalid path and aren't being regenerated because the *.py has not changed since then.

Wingware Support's avatar Wingware Support (2023-09-21 00:16:28 -0600) edit

Still no joy... There was indeed a __pycache__ folder in the mytest directory, so I deleted that. But running the code in MSYS2 creates the __pycache__ folder again with a wingdbstub.cpython-311.pyc file in it, but debugging still doesn't work.

Let me walk through creating a new project in Wing, and maybe you can spot where I'm going awry.

  • Project > New Project...
  • Create New Directory, name: mytest, Parent Dir: C:\msys64\home\jeff_
  • Project Type: Custom, Check "Use wingdbstub for Debugging", click Next
  • Use Existing Python, Command Line: C:\msys64\mingw64\bin\python.exe
  • click Create Project Project
  • completion message: "The project was successfully created and saved. The following actions were completed during project setup: Created source directory, set testing framework, added directory to project, configured wingdbstub.py, saved the project, set Python Executable, enabled debug listening"
  • File > New, add following code:

    #import wingdbstub #x = 4 / 0 print("Hello World!")

  • save as "mytest.py"

  • in MSYS2, go to ...
(more)
JeffH's avatar JeffH (2023-09-21 16:59:38 -0600) edit

I've reproduced it and will be looking into it. I mistakenly used the Cygwin python that comes with msys2 rather than the mingw python and the debugger is confused by the mingw python. I do think you need to use the mingw python with pygtk / gobject and probably want to use it anyway. It is too bad that there pygtk / gobject isn't available for python from python.org.

Wingware Support's avatar Wingware Support (2023-09-21 20:00:08 -0600) edit

Thanks so much for looking into this. Glad to know that I'm not as incompetent as I had feared... :-) Yes, it is sad that you only seem to be able to get pygtk / gobject through the MSYS2 environment. I found this info: "MSYS2 is the only supported way to run PyGObject apps in Windows." (See the comment from Dan Yeaw in this thread: https://gitlab.gnome.org/GNOME/pygobjec….) In previous iterations of pygtk / gobject, I could find an installer that would install it directly into my main Python environment, avoiding all these difficulties...

JeffH's avatar JeffH (2023-09-22 08:33:35 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer