I have created an ArcToolbox and a Model in the toolbox. It uses a lot of Spatial Analyst tools and deals with raster images.

When I imported the toolbox in a Python script and ran the model from Python in Windows command prompt, I got a few warning messages as below but the model got run successfully.

<string>:1: SyntaxWarning: import * only allowed at module level

It was shown several times. I am unable to tell where this error comes from.

Any idea?

  • 2
    Could you specify your problem a little bit more, e.g. by providing the script you are using to import toolbox and model? – Martin Dec 10 '13 at 6:24

Your warning message sounds similar to this ArcGIS Discussion Forum thread and the solution there seemed to be:

according to the help, the raster calculator is for use inside arcmap only, for calculations in python you should use mapalgebra: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm

Perhaps you are trying to use the Raster Calculator rather than Map Algebra in the Python code you are calling from outside ArcMap.

  • Yeah. I used Raster Calculator in the Model but not Python script. Then I made a Python script, imported the toolbox and called the Model from there. So it is not directly calling Raster Calculator from Python script. From the command prompt window, I could see it ran successfully with a few SyntaxWarning messages. – alextc Dec 11 '13 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.