I've previously posted a question about an ArcPy tool that walks through a specified area and scans all MXDs and associated Layers and reports them (as well as the inverse) Search for a shapefile of any kind and report all associated MXDs.

The issue is if a shapefile is used within a MXD hosted on ArcGIS Online, the script halts and ArcGIS prompts the user for login info. Until that window is closed, the script will not continue.

Can ArcPy detect this?

Can it be written into an exception and skipped?

I am familiar with exceptions and how they work.

  • As this is a programming specific question (Python and ArcPy), should this not stay within stack-overflow?
    – Matt
    Feb 29, 2016 at 16:08
  • 1
    ArcPy questions belong here, but any pure Python questions belong on Stack Overflow. This is an ArcPy and ArcGIS Online question, and is very on-topic here.
    – PolyGeo
    Mar 29, 2017 at 20:04

1 Answer 1


Temporary fix, though not what I was looking for: By adding a single line, arcpy will sign the user into ArcOnline for all files that request it:

arcpy.SignInToPortal_server("username", "password", "")

This effectively removes the halt but requires credentials to be saved within the script.

To further the malleability of this workaround, slap a couple variables in there:

usr = str(input("Enter Your Username:"))
pw = str(input("Enter Your Password:"))

arcpy.SignInToPortal_server(usr, pw, "")

Follow this link to the ESRI toolbox resources for more on this method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.