ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Script environments

  • Stand-alone or called scripts

Environments in script tools are like environments in any other tool—environment values are passed down to the script tool, where they are automatically applied to any tools run within the script. You can also set environments within a script tool, thereby overriding any passed-down environments. Environment values set within scripts only apply to the execution of the script; passed-down environment values are not altered. In the following sample script, the current workspace value is overridden in the script.

import arcpy
from arcpy import env

# Print the passed-down current workspace environment setting
#
arcpy.AddMessage("The passed-down current workspace is: %s" % env.workspace)

# Set a new workspace, overriding the passed-down workspace
#
env.workspace = "e:/data/script.gdb"
arcpy.AddMessage("The new current workspace is: %s" % env.workspace)

The following ArcPy functions allow you to manipulate environment settings:

  • ClearEnvironment
  • ListEnvironments
  • LoadSettings
  • ResetEnvironments
  • SaveSettings

Stand-alone or called scripts

There are two situations where the script does not receive passed-down environment settings. The first is when the script is run outside an ArcGIS application, such as from the operating system command prompt. The second is when a script calls another script: there is no way for the calling script to know that the called script will call geoprocessing functionality. In such situations, you can use the LoadSettings function, which can read environment settings from an XML file.

Related Topics

  • Using environment settings in Python
  • env
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal