Unresolved import problem with VS 2019 - please help

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
falviani
Posts: 250
Joined: Tue May 07, 2019 8:49 pm

Unresolved import problem with VS 2019 - please help

Post by falviani »

Hi,

I am trying to work on a workbench based on the workbench starter kit by Joel Graff. I am using VS2019 (python 3.8 environment), because I had too many problems trying to use VSCode and no proposed solution I found in these forums worked. When I open a python file in my project with the "usual" imports, i find this:

Code: Select all

Warning		unresolved import 'FreeCADGui'		C:\Users\frank\AppData\Roaming\FreeCAD\Mod\FC_TabbedBoxWorkbench\freecad\TabbedBoxWorkbench\init_gui.py	6
Warning		unresolved import 'FreeCAD'		C:\Users\frank\AppData\Roaming\FreeCAD\Mod\FC_TabbedBoxWorkbench\freecad\TabbedBoxWorkbench\init_gui.py	7	
Can anybody tell me how to resolve this? I searched already for the phrase "unresolved import" and found no useful info. Once I can resolve this I hope to move onto the next issue (or perhaps solving this will also solve that :) )

Thanks in advance,
Frank
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Unresolved import problem with VS 2019 - please help

Post by TheMarkster »

The way I debug with Visual Studio is first I startup FreeCAD. Then in VS19 debug menu -> attach to process -> attach to python code -> select FreeCAD in available processes, click Attach button.

Then I open my macro or workbench .py files in VS19, set breakpoints, and debug. There is a setting somewhere to have it recognize .FCMacro files as .py files. Somewhere.
falviani
Posts: 250
Joined: Tue May 07, 2019 8:49 pm

Re: Unresolved import problem with VS 2019 - please help

Post by falviani »

Thanks for the reply - I do exactly what you do, and it's pretty reliable. Except that when it hits a breakpoint it throws an exception complaining that "it's not a zipfile" - and I haven't been able to find any info about how to turn off that behavior. At least I can continue and actually debug.

Frank
Post Reply