Jump to content
UltiMaker Community of 3D Printing Experts

How to debug plugins during development?


Recommended Posts

Posted · How to debug plugins during development?

I am trying to develop a new plugin for the latest Cura (4.3 currently)


I've found the wiki page with some basic information (https://github.com/Ultimaker/Cura/wiki/Plugin-Directory) but could not find any info on how to debug/log during plugin development. 

How do I place breakpoints? How do I log to a console?


  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    Unfortunately, the --debug mode that shows the console output is broken on Windows. So to see the console output you need to run Cura from source. This is a bit involved, but here's my shortcut.


    In a project folder, check out Cura (from https://github.com/ultimaker/cura.git), Uranium (from https://github.com/ultimaker/uranium.git) and libCharon (from https://github.com/ultimaker/libcharon.git), each in thier own folder. Also create a folder named "bin". In that folder, you need to copy a number of files from the Cura 4.3 that you have installed:


    		... files from Cura.git ...
    		... files from Uranium.git ...
    		... files from libCharon.git ...

    Add the full path to the Uranium, libCharon and bin folders to your PYTHONPATH environment variable.


    Then you need to install a couple of python modules through pip or otherwise: colorlog, numpy, pyqt5, pyserial, scipy, trimesh, zeroconf.


    With all that done, you should finally be able to launch cura with ````````````"python cura_app.py" from the Cura folder and get all the console output as Cura starts. With "python -m pdb cura_app.py" you should be able to use the python debugger, but I don't use it much.

    • Thanks 3
    Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    Thanks, this is great help! 

    I was worried that I need to execute those 100+ steps to fully compile Cura. 

    Perhaps someone should post this to the wiki on GitHub.

  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    I'm not sure if I missed any steps; it has been >4 years since I have set up my development environment, but it is still what I use to develop my plugins. It skips compiling CuraEngine, so logically you can't make change to CuraEngine this way.

  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    As I just mentioned in https://github.com/Ultimaker/Cura/issues/6579


    you can happily use cura.exe --debug if you use a bash shell. I think it arrived with either mingw64 or a git installation.

  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    OK, I managed to run it following the instructions from @ahoeben. There were some extra steps needed:


    - It needs Python 3.5.x, 64bit with Python 3.8 I could not install PyQT5.10, just a newer one, that wont work (note that the install page at https://github.com/Ultimaker/Cura/wiki/Running-Cura-from-Source-on-Windows mentions 32 bit python, but I think one of the .pyd files was 64bits.).

    -These dependencies were enough: 

    numpy scipy colorlog zeroconf pyserial PyQt5==5.10 requests

    - Also i needed to install Shapely as described here: https://github.com/Ultimaker/Cura/wiki/Running-Cura-from-Source-on-Windows#python-352

    • Like 1
    • Thanks 1
    Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    Hello all!

    thank you @ahoeben and @hudejo for your instructions!

    I am trying to build a new plugin for Cura and want to debug it as well.
    My computer is running on windows 10 - 64 bit.
    So from both of your posts - here is what i did in order to make it run from source for me, i hope that my summary can help others like you helped me. thanks again :)

    1. Install python 3.5.4 - 64 bit (not 32!)
    2. Have cura 4.3 installation from website (used to retrieve some files later)
      -- from @ahoeben post:
    3. Create a project folder called “curaProject”
    4. Download projects cura, uranium and libCharon into the project folder so they are next to each other (I used versions 4.3 \ 4.3.0)
      From ultimaker github
    5. Additional files from Cura installation:
      create “bin” folder in “curaProject” folder.
      From the Cura installation folder, take the files just like ahoeben wrote (CuraEngine.exe, Arcus.pyd, Savitar.pyd, libgcc_s_seh-1.dll, libgomp-1.dll, libifcoremd.dll, libimalloc.dll, libiomp5md.dll, libmmd.dll, libstdc++-6.dll, libwinpthread-1.dll)
      And copy them to “bin” folder
    6. Add to windows PYTHONPATH the paths to uranium, libCharon and bin folder
    7. Install additional python packages - Python -m pip install numpy scipy colorlog zeroconf trimesh netifaces pyserial PyQt5==5.10 requests
      *** this is a combination from your posts + cura running on windows page - link
    8. Install Shapely package -
      1. Download Shapely‑1.6.4.post2‑cp35‑cp35m‑win_amd64.whl from here - link (https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely) - this is for 64 bit
      2. Install - python -m pip install [path to file]
    9. That’s it, good to go. Now you can run cura_app.py from the cura project
  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?


    How can I trace my PostProcessing script?


    I add to my script:


    import pdb
    def execute(self, data):


    I start Cura with "python3 -m pdb cura_app.py" then press "c" to continue.

    But I don't have stop on my script executing.


  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?

    Good morning,


    My python raise the following error:

    <unit>:\<path>\CuraProject\Cura>python cura_app.py
    Traceback (most recent call last):
      File "cura_app.py", line 29, in <module>
        from cura import ApplicationMetadata
    ImportError: No module named 'cura'


    I'm using the "Ultimaker Cura 4.6" and followed all the steps.


    If i use the -m pbd option:


    <unit>:\<path>\CuraProject\Cura>python -m pdb cura_app.py
    > <unit>:\<path>\curaproject\cura\cura_app.py(11)<module>()
    -> import sys
    (Pdb) c
    Traceback (most recent call last):
      File "<unit>:\<path>\Python35\lib\pdb.py", line 1665, in main
      File "<unit>:\<path>\Python35\lib\pdb.py", line 1546, in _runscript
      File "<unit>:\<path>\Python35\lib\bdb.py", line 431, in run
        exec(cmd, globals, locals)
      File "<string>", line 1, in <module>
      File "<unit>:\<path>\curaproject\cura\cura_app.py", line 11, in <module>
        import sys
    ImportError: No module named 'cura'
    Uncaught exception. Entering post mortem debugging
    Running 'cont' or 'step' will restart the program
    > <unit>:\<path>\curaproject\cura\cura_app.py(11)<module>()
    -> import sys
    (Pdb) cont
    Post mortem debugger finished. The cura_app.py will be restarted
    > <unit>:\<path>\curaproject\cura\cura_app.py(11)<module>()
    -> import sys
    (Pdb) quit



    and i don't know how to continue... 






  • Link to post
    Share on other sites

    Posted · How to debug plugins during development?
    I tried valiantly to load the modules and entities some people recommended here to no avail. So, I finally wrote a few modules to simulate Cura and call my post-processor. This worked great. The solution has been posted to my GitHub. I hope this helps someone out there. Ultimaker Cura Simulator to call Post-processor
  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.3 stable released
        In this stable release, Cura 5.3 achieves yet another huge leap forward in 3D printing thanks to material interlocking! As well as introducing an expanded recommended print settings menu and lots of print quality improvements. Not to mention, a whole bunch of new printer profiles for non-UltiMaker printers!
          • Thanks
          • Like
        • 22 replies
      • Here it is. The new UltiMaker S7
        The UltiMaker S7 is built on the success of the UltiMaker S5 and its design decisions were heavily based on feedback from customers.
        So what’s new?
        The obvious change is the S7’s height. It now includes an integrated Air Manager. This filters the exhaust air of every print and also improves build temperature stability. To further enclose the build chamber the S7 only has one magnetically latched door.
        The build stack has also been completely redesigned. A PEI-coated flexible steel build plate makes a big difference to productivity. Not only do you not need tools to pop a printed part off. But we also don’t recommend using or adhesion structures for UltiMaker materials (except PC, because...it’s PC). Along with that, 4 pins and 25 magnets make it easy to replace the flex plate perfectly – even with one hand.
        The re-engineered print head has an inductive sensor which reduces noise when probing the build plate. This effectively makes it much harder to not achieve a perfect first layer, improving overall print success. We also reversed the front fan direction (fewer plastic hairs, less maintenance), made the print core door magnets stronger, and add a sensor that helps avoid flooding.

        The UltiMaker S7 also includes quality of life improvements:
        Reliable bed tilt compensation (no more thumbscrews) 2.4 and 5 GHz Wi-Fi A 1080p camera (mounted higher for a better view) Compatibility with 280+ Marketplace materials Compatibility with S5 project files (no reslicing needed) And a whole lot more  
        Curious to see the S7 in action?
        We’re hosting a free tech demo on February 7.
        It will be live and you can ask any questions to our CTO, Miguel Calvo.
        Register here for the Webinar
          • Like
        • 18 replies
      • UltiMaker Cura Alpha 🎄 Tree Support Spotlight 🎄
        Are you a fan of tree support, but dislike the removal process and the amount of filament it uses? Then we would like to invite you to try this special release of UltiMaker Cura. Brought to you by our special community contributor @thomasrahm
        We generated a special version of Cura 5.2 called 5.3.0 Alpha + Xmas. The only changes we introduced compared to UltiMaker Cura 5.2.1 are those which are needed for the new supports. So keep in mind, this is not a sneak peek for Cura 5.3 (there are some really cool new features coming up) but a spotlight release highlighting this new version of tree supports.  
          • Like
        • 22 replies
    • Create New...