I'm trying to debug a python script in which passing arguments is required. Since I want to debug, using -b flag is not an option (otherwise there is no problem when running the code in a background mode).

I tried the following thing

filename = "/full/path/to/script.py --Arg1 arg1 ...."
exec(compile(open(filename).read(), filename, 'exec'))

Obviously that didn't work since exec tries to execute a file without additional arguments.

Few notes:

1) If I try to debug w/o passing arguments everything works fine I can debug and do what I want.

2) Some system pros: running docker container with 4 NVIDIA 1080-Ti cards on ubuntu os.

How can this be done?

  • $\begingroup$ Do you want to pass the arguments as part of the command line arguments? $\endgroup$ Commented May 4, 2020 at 9:41
  • $\begingroup$ @RobertGützkow | These examples demonstrate passing arguments in a background mode Blender. I want to debug my code, hence I need to run it from Blender's GUI. Any suggestions? $\endgroup$
    – AvivSham
    Commented May 4, 2020 at 10:58
  • 1
    $\begingroup$ Simply don't use the -b or --background argument? This will start Blender with GUI as usual. $\endgroup$ Commented May 4, 2020 at 11:01
  • 1
    $\begingroup$ Then it would be very helpful if you could give a precise description of what you're doing and what your goal is. I don't see why the PyCharm debugger wouldn't work when starting Blender from the command line, as long as the debugger is connected. Is this issue related to your old question? $\endgroup$ Commented May 4, 2020 at 11:46
  • 1
    $\begingroup$ With the limited information available, I'd say create two python scripts which are then called from the CLI. The first script connects the debugger by calling the operator that implements this feature (e.g. bpy.ops.debug.connect_debugger_pycharm if you're using the add-on from the old answer). The second script is the one you would like to test and pass arguments to. It has to be the last CLI argument, followed by the arguments you would like to pass into the script. $\endgroup$ Commented May 4, 2020 at 12:12


You must log in to answer this question.

Browse other questions tagged .