SDE connection works in console, not in script

07-06-2017 08:15 AM
New Contributor

I had a strange error that I've just tracked down. I'm posting it here in case anyone else has the same issue.

Scripts that used to work started failing, and the error was traced back to not properly connecting through the SDE file through a script. However, the problem was not the connection file itself, because it works in both ArcCatalog and the console within ArcMap.

As a sample, if I ran the following script through the ArcMap python console, the result was "DEWorkspace", meaning arcpy is recognizing the file as a valid connection file:

    desc = arcpy.Describe(r"C:\Users\path\to\connection.sde")

    print desc.dataElementType


However, if I ran this in an IDLE shell, the result is "DEFile", meaning arcpy is not recognizing the file as a valid connection:

    import arcpy

    desc = arcpy.Describe(r"C:\Users\path\to\connection.sde")

    print desc.dataElementType


This is just a representative sample of the errors. Anything I try to do using the SDE file (such as arcpy.da.ListVersions) works in console but not in a standalone script.

This article provided a clue, that it has to do with incompatible modules:

I uninstalled scipy and numpy using pip, then reinstalled numpy. My numpy version is now '1.13.0' (I'm not sure what it was before.) I'm currently not reinstalling scipy, because it does not play easily with Windows and I don't think I currently need it. 

This has fixed the problem, and I can now connect through sde files via scripts.


Windows 7 64-bit Service Pack 1

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32


Tags (2)
3 Replies
Occasional Contributor III

Today, in the version ArcGIS Server 11, it is happening again.

0 Kudos
by Anonymous User
Not applicable

Its been some time from the first post and I hope that you are no longer using Python 2.7.  What is your current environment?

0 Kudos
Occasional Contributor III
0 Kudos