Can't use shaper python code in yacs inline script node

I can’t use shaper python code in yacs inline script node. I creat a box in shaper and dump python code use salome.and i copy paste it into yacs it doesn’t work .but i use it in python consol it works. i don’t konw why.

#!/usr/bin/env python

###
### This file is generated automatically by SALOME v9.11.0 with dump python functionality
###

import sys
import salome

salome.salome_init()
import salome_notebook
notebook = salome_notebook.NoteBook()
sys.path.insert(0, r'C:/')

###
### SHAPER component
###

from salome.shaper import model

model.begin()
partSet = model.moduleDocument()

### Create Part
Part_1 = model.addPart(partSet)
Part_1_doc = Part_1.document()

### Create Box
Box_1 = model.addBox(Part_1_doc, 10, 10, 10)

model.end()

###
### SHAPERSTUDY component
###

model.publishToShaperStudy()
import SHAPERSTUDY
Box_1_1, = SHAPERSTUDY.shape(model.featureStringId(Box_1))

if salome.sg.hasDesktop():
  salome.sg.updateObjBrowser()


occured error.
but!!!when i use the code in python consol it works!