1

Not sure what's going on here with this module. Maybe a pathing issue?

  1. If I import the module from the python window in ArcMap it works.
  2. If I import it in a script, and use that script in a scriping tool the tool works.
  3. If I import it in a script and run the script, it fails. Error message says no module named arcgis.
  4. If I call the script tool from a Python add-in tool it fails and gives the same error message.

This worked on my computer at home but does not work on my computer at work.

Any ideas?

I'm using ArcGIS 10.1 and Python 2.7.2.

1
  • 1
    Could we get a sample of the script? Are you running up to date ArcGIS 10.1 SP1 on both computers? What about the background 64-bit geoprocessing add on? Commented Mar 13, 2013 at 18:32

1 Answer 1

1

The arcpy.rand() function is intended for use within a field calculation, not for direct use within the Python interpreter:

From Calculate Value (Data Management):

The arcgis.rand() function is supported. The arcgis.rand() function has been created for ArcGIS tools and should not be confused with the Python Rand() function.

If you'd like to use it elsewhere, you can use it via CalculateValue_management, like this:

result = arcpy.CalculateValue_management("arcgis.rand('normal 0.0 100.0')")
2
  • I'm using it with the CalculateField tool. Should I be using it with the CalculateValue tool instead?
    – dchaboya
    Commented Mar 13, 2013 at 23:29
  • 1
    Can you post a snippet of the code and what you're trying to do? If you're interested in updating the contents of a column, then CalculateField is correct. Please provide some code so we can see the context of the problem.
    – scw
    Commented Mar 14, 2013 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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