Failed when running arcpy.StageService_server('','' )

Discussion created by zhangsn on Mar 21, 2014
Latest reply on Dec 5, 2017 by nathanheick@lacsd.org
Hi guys, I am a Chinese young girl learning how to use Python to publish the map service. I have an error when I was trying to Stage Service (Server). The following is my code:

mapDoc = arcpy.mapping.MapDocument(mxd)
service = 'test'
sddraft = service + r'.sddraft'
sd = service + r'.sd'

analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER')
analysis = arcpy.mapping.AnalyzeForSD(sddraft)
analysis = arcpy.StageService_server(sddraft, sd)

I got an error said:
"Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\server.py", line 1140, in StageService
raise e
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (StageService)."

I dont know where is wrong. Can anyone have the same issue before? Or can provide me a help? Please. Thank you.