1

In my org we have issues of not having enough Arc licenses. I would like to be able to trap this, rather than have the python script blow up on me. My script bombs right at the import arcpy line when all licenses are in use. When there are licenses available, this works likes a charm.

here is the beginning of my script:

import os
import sys
import shutil
import arcpy

pathName = str(sys.argv[1])
print pathName

Here is the response:

Traceback (most recent call last):
  File "C:\Dropbox\Work\EclipseSrc\src\arcMapScripts\dluProc\arcPyNad27toNad83_Auto.py", line 4, in <module>
    import arcpy
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
    from geoprocessing import gp
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 568, in <module>
    env = GPEnvironments(gp)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 565, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 521, in __init__
    self._refresh()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in _refresh
    envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized

2 Answers 2

1

I was experiencing this issue and the resolution for me revolved around scheduled tasks that were also executing at the time. Apparently with a Desktop Advanced License you cannot have two scripts running at the same time that both import arcpy. Once the scheduled task finished, I was able to execute my script with no problems.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the CheckProduct function to check if licences are available. See this example copy/pasted from the Help page:

import sys
import arcpy

arcpy.env.workspace = "c:/data/world.gdb"

if arcpy.CheckProduct("ArcInfo") == "Available":
    arcpy.PolygonToLine_management("Lakes", "LakeLines")
else:
    msg = 'ArcGIS for Desktop Advanced license not available'
    print(msg)
    sys.exit(msg)

2 Comments

Thanks I'll try this out and let you know after the long weekend!
Never was able to recreate the error. The network has to be down. On un unrelated note, VPN from home I can never get a license. Just idles. So again not able to recreate the problem. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.