AnsweredAssumed Answered

arcpy import failures in some IDEs

Question asked by jbaughman_CL on Oct 25, 2017

Not a question, per se, because I've solved it, but since it's impossible to report a bug to ESRI, I wanted to make sure the fix was available somewhere.

In PyCharm and other IDEs, an attempt to import `arcpy` throws one of the two following errors:

error: [Errno 10054] An existing connection was forcibly closed by the remote host

or

error: [Errno 10053] An established connection was aborted by the software in your host machine

In the `interop.py` module, the docstrings for QuickImport and QuickExport contain URLs that do not have slashes properly escaped. Because the docstring isn't a raw string, the slashes are thus considered to start escape characters, as typical for Python string parsing. (\a seems to be the culprit in this case.) This causes an error on import in some IDEs. The fix is simple: escape out all slashes in URLs contained in the docstrings. Thus, instead of this:

* The ** characters match any subdirectories, recursively. For instance, c:\data\**\*.mif will match c:\data\roads.mif, c:\data\canada\rivers.mif, and c:\data\canada\alberta\edmonton.mif.

the docstring should include this:

* The ** characters match any subdirectories, recursively. For instance, c:\\data\\**\\*.mif will match c:\\data\\roads.mif, c:\\data\\canada\\rivers.mif, and c:\\data\\canada\\alberta\\edmonton.mif.

I manually edited `interop.py` to resolve the issue, but I was hoping to notify ESRI so that they could fix the issue on their end.

Outcomes