<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic arcpy: Could not open SDE workspace - sde filename dependency? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548477#M42799</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am having trouble with a arcpy script. I'm actuall not that familiar with python in general, and the current issue is really making me sick.&lt;/P&gt;&lt;P&gt;On a new environment, I installed a new Database and I want to setup there the same maintenance task as we already have on another environment. Part of this maintenance is a python script for compress, etc. But on the new environment the scripts aren't working. It always runs into error "TypeError: Could not open SDE workspace"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I made some tests on the current environment and found some very strange behaviour.&lt;/P&gt;&lt;P&gt;I have the following script (reduced to only few lines)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test.py&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;conn = 'C:\SDE\da.sde'&lt;BR /&gt;import arcpy&lt;BR /&gt;arcpy.AcceptConnections(conn, True)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the file da.sde exists.&lt;/P&gt;&lt;P&gt;But when I rename the file to test.sde, and change it of course in the pythin script, it throws:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;C:\SDE&amp;gt;test.py&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\SDE\test.py", line 5, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AcceptConnections(conn, True)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line&lt;BR /&gt;&amp;nbsp;1677, in AcceptConnections&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.acceptConnections(sde_workspace, accept_connections)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_bas&lt;BR /&gt;e.py", line 479, in acceptConnections&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self._gp.AcceptConnections(sde_workspace, accept_connections)&lt;BR /&gt;TypeError: Could not open SDE workspace.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;(This is also the actual error I &lt;STRONG&gt;always&lt;/STRONG&gt; get on the other environment.)&lt;/P&gt;&lt;P&gt;Switching both back to da.sde, works again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've testes several different filenames.&lt;/P&gt;&lt;P&gt;"da.sde" - works!&lt;/P&gt;&lt;P&gt;"test.sde" - fail&lt;/P&gt;&lt;P&gt;"datest.sde" - works&lt;/P&gt;&lt;P&gt;"abcde.sde" - fail&lt;/P&gt;&lt;P&gt;"wtf.sde" - works&lt;/P&gt;&lt;P&gt;"lmgtfy.sde" - works&lt;/P&gt;&lt;P&gt;"prod_sde.sde" - works&lt;/P&gt;&lt;P&gt;"b_prod_sde.sde" - fails&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure that the nameing is related to the issue on the other environment. But I got a little desperate with it, so that I hope unterstanding the nameing issue, may help me to make the script run elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lionel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Sep 2018 08:28:00 GMT</pubDate>
    <dc:creator>LionelMartz</dc:creator>
    <dc:date>2018-09-21T08:28:00Z</dc:date>
    <item>
      <title>arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548477#M42799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am having trouble with a arcpy script. I'm actuall not that familiar with python in general, and the current issue is really making me sick.&lt;/P&gt;&lt;P&gt;On a new environment, I installed a new Database and I want to setup there the same maintenance task as we already have on another environment. Part of this maintenance is a python script for compress, etc. But on the new environment the scripts aren't working. It always runs into error "TypeError: Could not open SDE workspace"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I made some tests on the current environment and found some very strange behaviour.&lt;/P&gt;&lt;P&gt;I have the following script (reduced to only few lines)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test.py&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;conn = 'C:\SDE\da.sde'&lt;BR /&gt;import arcpy&lt;BR /&gt;arcpy.AcceptConnections(conn, True)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the file da.sde exists.&lt;/P&gt;&lt;P&gt;But when I rename the file to test.sde, and change it of course in the pythin script, it throws:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;C:\SDE&amp;gt;test.py&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\SDE\test.py", line 5, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AcceptConnections(conn, True)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line&lt;BR /&gt;&amp;nbsp;1677, in AcceptConnections&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.acceptConnections(sde_workspace, accept_connections)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_bas&lt;BR /&gt;e.py", line 479, in acceptConnections&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self._gp.AcceptConnections(sde_workspace, accept_connections)&lt;BR /&gt;TypeError: Could not open SDE workspace.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;(This is also the actual error I &lt;STRONG&gt;always&lt;/STRONG&gt; get on the other environment.)&lt;/P&gt;&lt;P&gt;Switching both back to da.sde, works again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've testes several different filenames.&lt;/P&gt;&lt;P&gt;"da.sde" - works!&lt;/P&gt;&lt;P&gt;"test.sde" - fail&lt;/P&gt;&lt;P&gt;"datest.sde" - works&lt;/P&gt;&lt;P&gt;"abcde.sde" - fail&lt;/P&gt;&lt;P&gt;"wtf.sde" - works&lt;/P&gt;&lt;P&gt;"lmgtfy.sde" - works&lt;/P&gt;&lt;P&gt;"prod_sde.sde" - works&lt;/P&gt;&lt;P&gt;"b_prod_sde.sde" - fails&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure that the nameing is related to the issue on the other environment. But I got a little desperate with it, so that I hope unterstanding the nameing issue, may help me to make the script run elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lionel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 08:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548477#M42799</guid>
      <dc:creator>LionelMartz</dc:creator>
      <dc:date>2018-09-21T08:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548478#M42800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;Some failures&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;pth &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:\SDE\test.sde"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pth&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ---- ooops&lt;/SPAN&gt;
C&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\SDE&amp;nbsp; est&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sde

pth &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:\SDE\abcde.sde"&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ---- try again&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pth&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ----&lt;/SPAN&gt;
C&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\SDEbcde&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sde‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start by raw encoding your file paths&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;conn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\SDE\da.sde'&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ---- not the r in front of the path‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now raw encode them&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;pth &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\SDE\test.sde"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pth&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
C&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\SDE\test&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sde

pth &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\SDE\abcde.sde"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pth&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
C&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\SDE\abcde&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sde‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use double backslashes or forward slashes if you don't want to use the little 'r'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:43:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548478#M42800</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T23:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548479#M42801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;More on filenames and paths&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python"&gt;/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 09:22:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548479#M42801</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-09-21T09:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548480#M42802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried it, and now it works fine on current environment, independent on filename, thanks!&lt;/P&gt;&lt;P&gt;However, on the other environment it has no effect. still always getting the error. Printing the paths show all in the right way. Workspace works fine in ArcCatalog.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/422624_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works with python executed in ArcCatalog, gut not here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 09:31:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548480#M42802</guid>
      <dc:creator>LionelMartz</dc:creator>
      <dc:date>2018-09-21T09:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548481#M42803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;So obviously my initial issue on the other environment is not related to file names.&lt;/P&gt;&lt;P&gt;I checked out all the links I found on google.&lt;/P&gt;&lt;P&gt;- Everything is in 64bit, tried also both pythons&lt;/P&gt;&lt;P&gt;- arcpy.Exists(r"C:\SDE\test.sde") returns true&lt;/P&gt;&lt;P&gt;- setting arcpy.env.workspace to anything has no effect (setting it to C:\SDE and the connection fiel just test.sde)&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 11:36:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548481#M42803</guid>
      <dc:creator>LionelMartz</dc:creator>
      <dc:date>2018-09-21T11:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy: Could not open SDE workspace - sde filename dependency?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548482#M42804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got myself turned around reading through this thread.&amp;nbsp; After changing how you handle path names:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;In the new environment, outside of ArcCatalog, does the code work using any name for the SDE conn file?&lt;/LI&gt;&lt;LI&gt;In the new environment, from within ArcCatalog, does the code work using any name for the SDE conn file?&lt;OL&gt;&lt;LI&gt;When running the code in ArcCatalog, have you connected to any enterprise geodatabases before trying to run the code?&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-could-not-open-sde-workspace-sde-filename/m-p/548482#M42804</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-09-21T14:05:00Z</dc:date>
    </item>
  </channel>
</rss>

