Cannot access SDE from external Python Env

5894
7
11-24-2014 09:45 AM
JustinRobinson
New Contributor III

Hello Everyone,

I'm having a strange problem this morning that I've seen mentioned a couple time here on the forum without resolution.

Suddenly (as in, has changed in the last couple weeks) I am unable to access SDE connections through an external python interpreter (that is, one that is outside of ArcMap or ArcCatalog).

From within Arc's python window something such as

print [i.name for i in arcpy.Describe(r'path_to_sde_connections\user@current_sde_version.sde\dataset\feature_class').fields]

will work perfectly fine, but in an interpreter (the same version/site-packages as used by Arc) it will fail:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 1234, in Describe
    return gp.describe(value)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe
    self._gp.Describe(*gp_fixargs(args, True)))
IOError: "path_to_sde_connections\user@current_sde_version.sde\dataset\feature_class" does not exist

path_to_sde_connections\user@current_sde_version.sde\dataset\feature_class being a placeholder, this is generalized and has been tried with a number of sde connections, this print cmd works on non-sde gdbs.)

This is resulting in a script that I used and ran last month only working form being loaded into a python window within arc, where before I could run it from the command line.

Has anyone seen this before, or perhaps found a solution?

I can't begin to understand why suddenly this would occur. This is after a system reboot to ensure it would be conflict/lock-free. The only recent things I've done would be a pip update of lxml and pandas—which shouldn't be effecting it, as it works from within Arc.

Suggestions?

Tags (4)
7 Replies
DallasShearer
Occasional Contributor

when you define the path to the .sde file in your python script, is it the full path to the file? as in "c:\\working\\myDBConn.sde" or is it

"Database Connections\\myOtherDBConn.sde"

0 Kudos
XanderBakker
Esri Esteemed Contributor

I think either one is valid. Just tested using the full path and the one using "Database Connections" and both work in PyScripter...

0 Kudos
BlakeTerhune
MVP Regular Contributor

Same. Worked for me in PyScripter with ArcGIS 10.2.2 using a path to the local C:\ drive.

0 Kudos
JustinRobinson
New Contributor III

Yep, I am using a fully qualified path, both to a network location and to a local drive.

I can't reproduce it on other machines either, perhaps a reinstall will be required.

0 Kudos
LindseyWood
New Contributor III

I am having the same issue I upgraded from 10.0 to 10.2.2 everything works fine with the connection in Catalog and Map but not in Python... did the re-install work? I also found this

arcpy and SDE outside of ArcGIS

0 Kudos
LindseyWood
New Contributor III

So after much investigation, updating env variables from 10.0, installing service packs for 10.2.2 I figured it out! At least in my situation and probably Blakes too , my guess is that we were first using IDLE or python 64 and it was attached to X64 Python... is that standard with the install?

If I open and run it cmd line using X32 bit PYTHON under for me C:\python\27\ArcGIS10.2\python.exe it worked giving me my connection instance instead of just saying that it exists..... Same thing is my guess for Black that with PyScripter it was set to that 32 py.exe

Not sure if mine was because I already had Python 27 X64 installed when I had arc 10.0 installed for gdal purposes... however I do like to use IDLE so now my next move is...  uninstall arc and python? Or does anyone know how to reconfigure my IDLE to point to my X32 py? Or I guess I could just go get PyScripter but I am used to IDLE. I think they say it best here.

arcgis - Connecting to ESRI ArcSDE 10.2 for Oracle with ArcPy - Stack Overflow

Thanks!

0 Kudos
AsrujitSengupta
Regular Contributor III

Do you have Desktop and ArcGIS Server installed on the same box?

0 Kudos