Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoints are not hit in xlOil Python Debugging #109

Open
jxbean opened this issue Jul 17, 2024 · 7 comments
Open

Breakpoints are not hit in xlOil Python Debugging #109

jxbean opened this issue Jul 17, 2024 · 7 comments

Comments

@jxbean
Copy link

jxbean commented Jul 17, 2024

I have tried to set up debugging in VS Code and Visual Studio, but neither has been able to break at the breakpoint. Is there a more detailed tutorial on debugging? I saw some settings for debugging pyxll in PyCharm online and tried to set it up accordingly, but it didn't work.

@cunnane
Copy link
Owner

cunnane commented Aug 9, 2024

At one time it was possible to use Visual Studio to attach to a running Excel process, then open a py file containing an xlOil funcion, add breakpoints and they would be hit. Trying this now, it no longer seems to work. As a workaround, you can create an empty C++ project in Visual Studio, then in the debug settings chose C:\Program Files...\Excel.exe as the debug target and the "python/native" debugger:

image

When I launch Excel like this, I can hit breakpoints in xlOil py functions. It's not particularly convenient so I'll experiment with other options. Unfortunately I don't have PyCharm Pro, so can't test out its embedded python debugging.

@jxbean
Copy link
Author

jxbean commented Aug 12, 2024

Thank you for the explanation. I’m unsure how to integrate the Python file with this empty C++ project. What should the complete project structure look like? How should I add my Python scripts properly and set breakpoints?

@keithalewis
Copy link

I don't know how to solve this issue, but you can use $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe) as the Debugging Command to start Excel no matter where it was installed.

@cunnane
Copy link
Owner

cunnane commented Aug 12, 2024 via email

@jxbean
Copy link
Author

jxbean commented Aug 13, 2024

Thanks again. It seems that there is a requirement for the python version, and 3.9 version is recommended and needs to install debugging symbols for Python interpreters in Visual Studio. It works for me now.

@cunnane
Copy link
Owner

cunnane commented Aug 25, 2024

Btw nice trick @keithalewis !

@jxbean
Copy link
Author

jxbean commented Sep 6, 2024

Setting the 'launch.json' file with the 'Attach using Process Id' method as below in vscode works, and Python versions higher than 3.9 works fine.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Attach using Process Id",
            "type": "debugpy",
            "request": "attach",
            "processId": "${command:pickProcess}",
            "connect": {
                "host": "127.0.0.1",
                "port": 5678
            },
            "justMyCode": true,
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "${workspaceFolder}"
                }
            ]
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants