ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

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
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

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

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

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

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2017 Esri. | Privacy | Legal