'Object does not have geometry data' error when running headless? I have the following blender python script:
import bpy
from random import randint

#how many cubes you want to add
count = 10

for c in range(0,count):
    x = randint(-10,10)
    y = randint(-10,10)
    z = randint(-10,10)
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    print(f'Cube added at coordinates: {x}{y}{z}')
    
bpy.ops.export_mesh.stl(filepath=&quot;C://Users//diego//OneDrive//CFD//output.stl&quot;)

And it works perfectly when called by blender --python script.py
but fails when called by blender -b --python script.py, I get the following error:
Error: Object does not have geometry data
Error: Object does not have geometry data

Blender quit
Quoting from https://docs.blender.org/api/242PythonDoc/API_related-module.html :
Background mode examples:
# Open Blender in background mode with file 'myfile.blend'
# and run the script 'script.py':

blender -b myfile.blend -P script.py

# Note: a .blend file is always required.  'script.py' can be a file
# in the file system or a Blender Text stored in 'myfile.blend'.

I have tested it but you can try adding a file in your command line options