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

1999
3
06-14-2016 08:22 AM
FredricRagnar
New Contributor

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?

Tags (3)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

you are presumably using background processing Background Geoprocessing (64-bit)—Help | ArcGIS for Desktop

are both versions of python available and installed? is this a custom install or did you use the esri supplied distributions?

0 Kudos
FredricRagnar
New Contributor

Yes, it is the background processing package. Both ESRI supplied packages are installed and I need the background processing to utilize the x64 architecture better.

0 Kudos
DanPatterson_Retired
MVP Emeritus

hmmmm in a case like that I normally would check for a path file for the 2.7 version it is located in

C:\Python27\ArcGIS10.4\Lib\site-packages called called Desktop10.4.pth and in my case contains

C:\Program Files (x86)\ArcGIS\Desktop10.4\bin

C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy

C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolBox\Scripts

but I don't use python 2.7 with arcmap 10.4.1 since I have ArcGIS Pro installed and I use python 3.4 instead

0 Kudos