error: global name 'Primary_OH' is not defined

4477
43
Jump to solution
12-27-2019 11:14 AM
RickHawkins
New Contributor II

I am trying to run my program and when i get to this part of the program

I get the error that global name 'Primary_OH is not defined. Can someone look at my code and tell what i need to do to fix this.

Thanks

Tags (1)
0 Kudos
43 Replies
Javier_AntonioEscudero
Esri Contributor

Hi Rick, 

The gdb file (File Geodatabase) is the most popular container of data in ArcGIS. However, mxd files can contain multiples types of files and containers (Data sources).

In order to get the Primary_OH_Path of yout layer follow these steps:

  • Open your map document "C:/GISMAPS/LUS Map.mxd"
  • Clic on Primary_OH layer properties 

  • Go to Source tab and explore data source properties of the layer

0 Kudos
RickHawkins
New Contributor II

Joe,

I guess i will have to change the lines to some other command. What i am trying to do here is go to the properties of a layer and create a definition query (i.e. -  [FEEDERID] = "2050") and turn off all of the feeders for that layer (Primary OH) that are not numbered 2050. Am i doing this wrong? Is there another way to do this?

Thanks

0 Kudos
RickHawkins
New Contributor II

Javier,

When i do that i get the following:

There is no .gdb database.

0 Kudos
MichaelVolz
Esteemed Contributor

Rick:

You should copy the data to a file gdb from the personal geodatabase that you are currently using as ESRI is migrating to Pro which does not support personal geodatabases that you are using.  File geodatabases can be used in both ArcMap (32-bit) and Pro (64-bit).

Javier_AntonioEscudero
Esri Contributor

OK. It does not matter. The container of data is a Personal Geodatabase, is so similar to File Geodatabase


# Primary OH Path
geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"
Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class) 
Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH")

RickHawkins
New Contributor II

thanks everyone for you help. i will see what i need to do to copy the data to a .gdb file.

Will get back with you when this is completed.

0 Kudos
Javier_AntonioEscudero
Esri Contributor

You can try testing your script using personal geodatabase for now.


But, as Michael recommends, you should evaluate to migrate your data to File Geodatabase to better support.

0 Kudos
RickHawkins
New Contributor II

Javier,

i entered the code that you suggested:

When running it i get the following errors:

0 Kudos
Javier_AntonioEscudero
Esri Contributor

Rick

Try to set another name to the layer object, like "Primary_OH_Layer1", or something like that.

Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer1")
0 Kudos
RickHawkins
New Contributor II

i did put this code at the beginning 

geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"

0 Kudos