AnsweredAssumed Answered

Pycharm and ArcGIS Pro compatibility: scripts work in Python window but not in Pycharm

Question asked by qvt2_pdxedu on Jan 14, 2020
Latest reply on Jan 15, 2020 by bixb0012

Hi there, I've installed PyCharm as per the the ESRI course "Python for Everyone" and was able to get through the entire course without problem. 


However, when I try to run a script I am starting to write on Pycharm, though it runs with no errors, I am getting odd results. I test the script statements in Python window and am able to get the results I am expecting, but when I run them through Pycharm I get a completely different result. 


Can somebody help me with this? 


This is the simple piece of code I am running: 

import arcpy
import os

workspace = r'C:\Users\paperspace\Google Drive\QTA\19010_PDX Zoning\PDXZoning\PDXZoning.gdb'
outWorkspace = r'C:\Users\paperspace\Google Drive\QTA\19010_PDX Zoning\PDXZoning\PDXZoned.gdb'
arcpy.env.workspace = workspace

# set the target address taxlot
# consider capitalizing whatever user inputs
address = "1519 SE MORRISON ST"
field = arcpy.AddFieldDelimiters('taxlots', 'SITEADDR')
query = field + " LIKE '%" + address + "%'"

# select the target taxlot
arcpy.SelectLayerByAttribute_management('taxlots', 'NEW_SELECTION', query)

# test output--you can remove this once done testing
outFC_temp = os.path.join(outWorkspace, 'tempARE09')
if arcpy.Exists(outFC_temp):
arcpy.CopyFeatures_management('taxlots', outFC_temp)

 When I copy and paste into Python Window, I get the result I am expecting, which is the selection of a specific taxlot in a cadastral map with the SQL query. 


When I run this same script in Pycharm, the script runs fine, but gives me a completely different result (a different taxlot, strangely). Other geoprocessing commands don't seem to do anything, either. 


I can't tell if I am passing the SQL query incorrectly, writing the output file incorrectly, or if I have incorrectly pointed to the correct Python interpreter. However, the script works fine in Python Window and 


This is my Pycharm interpreter, which I believe is pointing to the right spot: 

However, when I double click on the executable from explorer I get this: 

Which seems weird to me but everything else seems to run fine. 


Any help would be appreciated.