AnsweredAssumed Answered

Is it possible to configure the conditions for the imports for an arcpy script?

Question asked by fredric_ragnar on Jun 14, 2016
Latest reply on Jun 15, 2016 by Dan_Patterson

This is a truncated logging output from a verbose run of an arcpy script with only an import of arcpy:

. . .

import re # precompiled from C:\Python27\ArcGISx6410.4\Lib\re.pyc

# C:\Python27\ArcGISx6410.4\Lib\sre_compile.pyc matches C:\Python27\ArcGISx6410.4\Lib\sre_compile.py

import sre_compile # precompiled from C:\Python27\ArcGISx6410.4\Lib\sre_compile.pyc

import _sre # builtin

# C:\Python27\ArcGISx6410.4\Lib\sre_parse.pyc matches C:\Python27\ArcGISx6410.4\Lib\sre_parse.py

import sre_parse # precompiled from C:\Python27\ArcGISx6410.4\Lib\sre_parse.pyc

# C:\Python27\ArcGISx6410.4\Lib\sre_constants.pyc matches C:\Python27\ArcGISx6410.4\Lib\sre_constants.py

import sre_constants # precompiled from C:\Python27\ArcGISx6410.4\Lib\sre_constants.pyc

import _locale # builtin

# C:\Python27\ArcGISx6410.4\Lib\locale.pyc matches C:\Python27\ArcGISx6410.4\Lib\locale.py

import locale # precompiled from C:\Python27\ArcGISx6410.4\Lib\locale.pyc

import encodings # directory C:\Python27\ArcGISx6410.4\Lib\encodings

# C:\Python27\ArcGISx6410.4\Lib\encodings\__init__.pyc matches C:\Python27\ArcGISx6410.4\Lib\encodings\__init__.py

import encodings # precompiled from C:\Python27\ArcGISx6410.4\Lib\encodings\__init__.pyc

# C:\Python27\ArcGISx6410.4\Lib\codecs.pyc matches C:\Python27\ArcGISx6410.4\Lib\codecs.py

import codecs # precompiled from C:\Python27\ArcGISx6410.4\Lib\codecs.pyc

import _codecs # builtin

# C:\Python27\ArcGISx6410.4\Lib\encodings\aliases.pyc matches C:\Python27\ArcGISx6410.4\Lib\encodings\aliases.py

import encodings.aliases # precompiled from C:\Python27\ArcGISx6410.4\Lib\encodings\aliases.pyc

import operator # builtin

# C:\Python27\ArcGISx6410.4\Lib\functools.pyc matches C:\Python27\ArcGISx6410.4\Lib\functools.py

import functools # precompiled from C:\Python27\ArcGISx6410.4\Lib\functools.pyc

import _functools # builtin

# C:\Python27\ArcGISx6410.4\Lib\encodings\cp1252.pyc matches C:\Python27\ArcGISx6410.4\Lib\encodings\cp1252.py

import encodings.cp1252 # precompiled from C:\Python27\ArcGISx6410.4\Lib\encodings\cp1252.pyc

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

import arcpy # directory C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy

import arcpy # from C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py

. . .

 

It seems that the python interpreter is invoked a second time within the script prior to the "import arcpy". This gives unexpected consequences when running an arcpy script on a Windows Server via remotely executed command through SSH link, OpenSSH Server installed in Cygwin environment. The script terminates immediately at the "import arcpy" call. Running the arcpy script while being logged in the arcpy script continues the execution and produces the expected output.

The arcpy script also works as expected when run locally on the server in a command prompt.

 

Is there a way to configure the python environment so that the arcpy import is completed and not aborted?

Outcomes