Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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? –  Quentin Walker Mar 13 '13 at 18:32
add comment

1 Answer

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')")
share|improve this answer
    
I'm using it with the CalculateField tool. Should I be using it with the CalculateValue tool instead? –  dchaboya Mar 13 '13 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 Mar 14 '13 at 5:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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