I am facing a very weird issue in setting the workspace. When I setup the workspace inside python window in ArcMap/ArcCatalog, it just works fine. But the moment I do the same in a standalone python script, the things do not work at all. I tried other options like creating connection file in scratch folder and then setting it as a workspace but still no luck. I am facing this issue on ArcGIS Desktop 10.2.1 and my database is 64 bit Oracle.
I had ArcGIS Pro 2.1 installed on the same machine hence I also tried the same thing after uninstalling ArcGIS Pro but still no luck.
Option1
Import arcpy
arcpy.env.workspace = r‘Database Connections\Connection to sde.sde’
print arcpy.ListDatasets()
Option2
Import arcpy
arcpy.env.workspace = r‘C:\Users\<MyUserName>\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Connection to sde.sde’
print arcpy.ListDatasets()
Result in Python Window within ArcMap : [‘dataset1’, ‘dataset2’]
Result in Pyscripter : None
I don't have pyscripter but I can run this in an idle shell:
Here how it happens even when I try the same in IDLE
I wonder if it's bombing on the spaces in your actual paths.
Dan Patterson ; care to comment?
I zone out whenever I see SDE anywhere
Ha, ha,
But I also zone out when I see this sort of stuff...
>>> X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]>>> positions = np.vstack([X.ravel(), Y.ravel()])>>> values = np.vstack([m1, m2])
What does it mean.....
Just numpy messing with you Neil.
Dan- I think because SDE isn't pc any more. It's really Enterprise Geodatabse....
Tried after getting rid of spaces as well, same result. This is driving me crazy since a week!
Can you also try arcpy.Exists(r"path to sde connection file.sde")
Yes, I did this test as well. It conforms that the path does exists.