I'm using Arcgis 10.1 and I created my script for inserting data in my feature class but I got this error message:

Traceback (most recent call last):
  File "C:\SIG_AS\Shapefiles\Projet2\MyScript\Insert_chantiers_gp.py", line 35, in <module>
    with arcpy.da.InsertCursor( inGeodatabase, fieldsToUpdate) as cursor:
RuntimeError: cannot open 'Chantiers.shp'

And this is my script for inserting my data into my feature class:

# Ajout de champs
import arcgisscripting
import arcpy
# Définir l'environnement
arcpy.env.workspace = "C:/SIG_AS/DB/Chantiers.gdb"

# creation de l'objet gp (arcgisscripting est l'ancêtre d'arcpy et devait être créé à chaque fois)
gp = arcgisscripting.create(9.3) 
# Paramètres d'entrée
inDescription = gp.GetParameterAsText(0)
inRestriction = gp.GetParameterAsText(1)
inNumero = gp.GetParameterAsText(2)
inNomVoie = gp.GetParameterAsText(3)
inDate1 = gp.GetParameterAsText(4)
inDate2 = gp.GetParameterAsText(5)
inLat = gp.GetParameterAsText(6)
inLong = gp.GetParameterAsText(7)

# Variables de champs
inGeodatabase = "Chantiers.shp"
ObjectidField = "OBJECTID"
ShapeField = "SHAPE"
descriptionField = "Desc_travaux"
restrictionField = "Restriction_trafic"
numeroField = "Numero_civique"
nomField = "Nom_voie"
date1Field = "Date_debut"
date2Field = "Date_fin"
LatField = "Latitude"
LongField = "Longitude"

#Tuple pour mise à jour des champs
fieldsToUpdate = ( ObjectidField, ShapeField, descriptionField, restrictionField, numeroField, nomField, date1Field, date2Field, LatField, LongField)
# Curseur d'insertion
with arcpy.da.InsertCursor( inGeodatabase, fieldsToUpdate) as cursor:
# Insertion de ligne aux attributs considérés
    cursor.insertRow((inDescription, inRestriction, inNumero, inNomVoie, inDate1, inDate2, inLat, inLong))

2 Answers 2


It appears to be trying to open C:/SIG_AS/DB/Chantiers.gdb/Chantiers.shp, but feature classes in geodatabases are not shapefiles. If the feature class is in fact in that geodatabase and is called "Chantiers", try inGeodatabase = "Chantiers". Otherwise, change arcpy.env.workspace to the folder containing Chantiers.shp.


Your workspace is a geodatabase (C:/SIG_AS/DB/Chantiers.gdb); however, you're trying to open Chantiers.shp. Shapefiles cannot exist in a geodatabase. Either Chantiers is a feature class within the gdb, and you meant to pass only Chantiers (without the .shp) to the variable inGeodatabase (which is a terribly misleading variable name, by the way), or you have a shapefile named Chantiers elsewhere that you're trying to reference. In that case, assign the full path of Chantiers.shp to the variable.


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.