I have these lines of code:

import tkFileDialog, arcpy, arcpy.da, numpy as np, Tkinter
import arcpy.mapping as mapping

fc = tkFileDialog.askopenfilename(filetypes=[('shapefiles','*.shp')],title='Choose a Shapefile')
print 'fc = {0}'.format(fc)
desc = arcpy.Describe(fc)

#Find the number of rows(alternatives) and print it!
number_of_rows = arcpy.GetCount_management(fc)
R = int(number_of_rows.getOutput(0))
print R
#Find the number of columns(criterias) and print it!
C = len(arcpy.ListFields(fc))
print C

It creates a GUI where i can browse and open a shapefile. This shapefile is an ArcMap shapefile with a layer and an attribute table. With this algorithm i get this error:

Traceback (most recent call last):
  File "C:\Users\Th\Desktop\Python Scripting\Σμαραγδάς Αθανάσιος     Διπλωματική\Python Codes\Python_Codes\Script1.py", line 8, in <module>
    number_of_rows = arcpy.GetCount_management(fc)
  File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 13613, in GetCount
raise e
ExecuteError: ERROR 000229: Cannot open C:/Users/Th/Desktop/waterways.shp
Failed to execute (GetCount).

How can i solve this? I can access the file with the line below and do the same work with it, but i want to create a GUI so that i can open any file i want to by browsing.

fc = "C:/Users/Th/Desktop/waterways.shp"

I am trying to open the file with the GUI and then use it for any reason i want.But after it prints the directory of the file(as the algorithm demands), i get the error above.

  • 1
    Does it work when you manually add it? Jun 23, 2016 at 21:21
  • Yes it does work perfectly. @JamesLeversha Jun 23, 2016 at 21:22
  • 1
    I have worked with tkFileDialog and did not have a problem. What does the print 'fc = {0}'.format(fc) output? Jun 24, 2016 at 3:49
  • Also do a print desc after desc = arcpy.Describe(fc) to see if a describe object is getting created. Maybe try and set the workspace variable in the code, arcpy.env.workspace = fc = tkFileDialog.askopenfilename(filetypes=[('shapefiles','*.shp')],title='Choose a Shapefile') Jun 24, 2016 at 7:19
  • fc = {0}'.format(fc) prints the path of fc: fc = C:/Users/Th/Desktop/waterways.shp @BenSNadler Jun 24, 2016 at 8:10

1 Answer 1


As commented by @PauloRaposo:

[This m]ight be an Esri bug ... See this on Error 000229, about background processing being enabled: http://support.esri.com/technical-article/000012177. Your code works just fine for me in a Python console using one of my own shapefiles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.