Not able to set workspace using standalone Python script for ArcGIS

2833
28
08-21-2018 11:51 PM
HarshalGharat
New Contributor II

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.

0 Kudos
28 Replies
Jose_AlvaroSanchez_Huamani
New Contributor

I had the same problem. This works when you set in PyScripter, menu Run, Python Engine, Internal.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

I like to use ArcCatolog to provide the the path:  with it open, navigate to the workspace and up at the top of the window is the actual path.  Click, copy and paste it into your code:

arcpy.env.workspace = r'X:\your\copied\path\here'
That should just about do it....
HarshalGharat
New Contributor II

Not working for me

0 Kudos
JoeBorgione
MVP Esteemed Contributor

I hate it when that happens; thing is, your actual path names have spaces in them, right?  If you take them out in the python script it's not going t find them....

That should just about do it....
0 Kudos
HarshalGharat
New Contributor II

I meant, I created a new connection file in a directory where the sde file and directory name didn't have any spaces.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Hmmm.  As you stated in your op; this is weird issue.  Not sure what's going on here....

That should just about do it....
0 Kudos
HarshalGharat
New Contributor II

I have raised a ticket with Esr tech support on this, will keep you posted

0 Kudos
JoeBorgione
MVP Esteemed Contributor

That's the route to go at this point.  It's just so very odd...

That should just about do it....
0 Kudos
NikolaCacanoski
New Contributor II

I had the same problem, and I solved it with copying the sde file to location where there won't be space character in the path. Also, I have renamed the sde file. Example: C:\sde\myconnection.sde