I have had a Python 2/ArcMap script to compress enterprise geodatabases. The script has worked fine for a while now. I recently converted the script to Python 3/ArcGIS Pro. Now, I keep getting the same error (see below). I've tried referencing the sde connection files using os.path.join and as a single variable (drive/letter/file). I'm looping through a list of geodatabases.
Error: Failed to execute. Parameters are not valid.
ERROR 000837: The workspace is not the correct workspace type.
Failed to execute (Compress).
FILE: compress_geodatabases.py, LINE: 41
"arcpy.management.Compress(gdb[0])": Failed to execute. Parameters are not valid.
ERROR 000837: The workspace is not the correct workspace type.
Failed to execute (Compress).
Error compressing CCGIS.sde
<SPAN class="comment token"># compress geodatabases</SPAN>
<SPAN class="keyword token">for</SPAN> gdb <SPAN class="keyword token">in</SPAN> geodatabases<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># start time for compress</SPAN>
start_time_compress <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>perf_counter<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># compress tool</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>management<SPAN class="punctuation token">.</SPAN>Compress<SPAN class="punctuation token">(</SPAN>gdb<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># end time for compress</SPAN>
end_time_compress <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>perf_counter<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># elapsed time compress</SPAN>
elapsed_time_compress <SPAN class="operator token">=</SPAN> end_time_compress <SPAN class="operator token">-</SPAN> start_time_compress
<SPAN class="comment token"># round elapsed time</SPAN>
elapsed_time_compress_rounded <SPAN class="operator token">=</SPAN> round<SPAN class="punctuation token">(</SPAN>elapsed_time_compress<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># add message</SPAN>
log_message <SPAN class="operator token">+=</SPAN> <SPAN class="string token">'\nCompressed {} in {}-seconds\n'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>gdb<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> elapsed_time_compress_rounded<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN> EnvironmentError <SPAN class="keyword token">as</SPAN> e<SPAN class="punctuation token">:</SPAN>
log_message <SPAN class="operator token">+=</SPAN> print_errors<SPAN class="punctuation token">.</SPAN>print_exception<SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">)</SPAN>
log_message <SPAN class="operator token">+=</SPAN> <SPAN class="string token">'\nError compressing {}\n'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>gdb<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN> Exception <SPAN class="keyword token">as</SPAN> e<SPAN class="punctuation token">:</SPAN>
log_message <SPAN class="operator token">+=</SPAN> print_errors<SPAN class="punctuation token">.</SPAN>print_exception<SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">)</SPAN>
log_message <SPAN class="operator token">+=</SPAN> <SPAN class="string token">'\nError compressing {}\n'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>gdb<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># end for in</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>