Select to view content in your preferred language

Upgrade to ArcGIS 10.3 produces strange behavior with Python

5916
10
Jump to solution
01-05-2015 09:45 AM
by Anonymous User
Not applicable

I have recently upgraded to ArcGIS 10.3 and all my script tools are not working.  For some reason, within any ArcGIS process, the built-in sys module does not have the argv attribute.  It works as expected in stand-alone.  This affects me because I use sys.argv in virtually all the script tools I have developed for my organization (70+) to pass in arguments.

For example, if I have a function like this:

def function(arg1, arg2, arg3):
    pass

It is easier to call the function and pass in parameters from a script tool like this:

function(*sys.argv[1:])

rather than:

param1 = arcpy.GetParameterAsText(0)
param2 = arcpy.GetParameterAsText(1)
param3 = arcpy.GetParameterAsText(2)

function(param1, param2, param3)

However, after the upgrade, ONLY in any ArcGIS process the sys module is lacking the argv attribute.  See pictures below:

fails in ArcGIS Python Window

ags_pywin.PNG

and works as expected in regular IDLE shell

idle.PNG

Is there something different about how ArcGIS is accessing Python in version 10.3?

Tags (2)
10 Replies
by Anonymous User
Not applicable

Hi Susan,

I ended up having to uninstall/re-install to fix the issue.  The corrupted install did place Python in the proper directory under ArcGIS, and the sys module seemed to have everything but argv.  This actually happened to me the first day I installed it, but when I called reload(sys) in ArcMap it seemed to work again the next time I opened it.  This did not work today though.

What I didn't understand is why I was getting the correct results from dir(sys) when running from IDLE, but not from ArcMap. I always make sure to clear out all Python stuff after I uninstall each version to be safe.  I am up and running now though.

I should add I read somewhere that this was a bug at one time with the original release of python 2.7.8.  I'll try to find the link.