Questions tagged [nameerror]

Use when NameError from Python is thrown by your code

Filter by
Sorted by
Tagged with
3
votes
1answer
36 views

Getting NameError on GetParameterAsText

I am trying to write a simple script that get input from a variable in ModelBuilder and use it in a Python script to "zoom" on a selected features in layout. Here is the script and the error:...
0
votes
0answers
46 views

Writing shapefile attribute to text file using ArcPy with ArcGIS Pro gives NameError: name 'getValue' is not defined

I am using ArcGIS Pro 2.9.0. I'm trying to write the attribute of a shapefile to a text file and every time I run the code I get this error: NameError: name 'getValue' is not defined Below is the ...
0
votes
1answer
36 views

How to add user input shapefile as a parameter into "GDB Creator" Python Script tool

I created a Python Script tool to create a GDB inside of a user defined folder path. I am trying to find a way to add another parameter in my script tool for a user to input a shapefile after they ...
0
votes
0answers
39 views

Output of first iteration as the input of the next step in a for loop

I use a Python script to find the closest facilities. I have 24 cities to process. For one city, I should create 100 random datasets. To do that, I use Python, and for loops. After I create the random ...
3
votes
0answers
128 views

Reading files with Japanese filenames with GeoPandas

I'm trying to read all shapefiles in a folder using this script: import glob import geopandas as gpd infolder = r'E:/folder/test_input' shapefiles = glob.iglob(infolder+'/*.shp') gdfs = [gpd....
7
votes
2answers
721 views

NameError: name 'QMessageBox' is not defined

When I'm loading a CSV into QGIS, I get this error code, see below. Does anyone know what this means? This also is an issue when I attempt to run NNJoin Plugin too. An error has occurred while ...
3
votes
1answer
264 views

Using sym.renderer.fields with ArcPy and ArcGIS Pro gives NameError: attribute 'fields' not supported on instance of UniqueValueRenderer

I have a script that updates the symbology of layers in ArcGIS Pro 2.5.0 with Python 3.6: if lyr.name == "Oiling Zone": sym = lyr.symbology sym.updateRenderer('UniqueValueRenderer') sym....
1
vote
1answer
201 views

PyQGIS script for loading several .xyz files into QGIS gives NameError

I found a script for loading several csv files into QGIS and modified it for .xyz Data. Yesterday on one Computer it worked and today on a different Computer it's not working anymore. Is there ...
1
vote
1answer
133 views

Avoiding Python NameError when rewriting script with user defined functions for ArcGIS Pro

I am rewriting a script for Python 3.6 and ArcGIS Pro compatibility and it seems like user defined functions will be necessary to clean it up. I am fairly new. I separated the code block into two ...
2
votes
1answer
59 views

Extracting Summary Statistics value with cursor and assigning it to a variable

I am writing a script (to be used in ArcGIS 10.7.1) that uses a Zonal Statistics tool to create an average of a raster that is beneath a grid. I then use the Summary Statistics tool to take the ...
0
votes
1answer
40 views

Python code error - NameError [closed]

I am relatively new to writing Python code so this is probably obvious to most of you but I am receiving the following error: NameError: name 'latest_edition' is not defined > # Import system ...
0
votes
1answer
219 views

Exporting attribute tables of rasters using ArcPy

I have this script that worked once before to export the attribute tables of some rasters as CSV files. However when I run this script again, I get an error: Runtime error Traceback (most recent call ...
1
vote
1answer
448 views

NameError: name '**' not defined in ModelBuilder Calculate Value

This question follows up on Crianopa's answer https://gis.stackexchange.com/a/107687/126329 - I am attempting to do just this, but my model fails at the Calculate value stage. Using the expression ...
1
vote
1answer
45 views

SAGA Raster Calculator processing script give error "name 'Rasterout' is not defined"

I am trying to build a custom script using things I have learned from this post: Number inputs as raster calculator variables in QGIS Modeler This is my script so far: ##Maechtigkeit unterhalb einer ...
2
votes
0answers
2k views

NameError: name data_all1 is not defined in Python 3.x

I have a standalone script using data opened from a Geopackage with Fiona. When I run this portion of my script: import os import fiona import numpy as np datapath= '/media/sf_SharesShapefiles/' ...
0
votes
1answer
7k views

NameError: name '**' is not defined

After importing PyQt4.QtCore,PyQt4.QtGui and processing and after having correctly defined layers, I executed this script in PyQGIS but it returns this error: Traceback (most recent call last): ...
2
votes
1answer
341 views

Debugging NameError: name 'QgsLinearlyInterpolateDiagramRenderer' is not defined from PyQGIS?

I have gone through an online tutorial on how to do a pie chart map using PYQGIS. The following is my code, identical to what was provided. # -*- coding: utf-8 -*- from PyQt4.QtGui import* from ...
4
votes
2answers
505 views

Layers visibility- code error in Arcpy

I try to turn of all the layers, using this code using ArcGIS 10.3.1: import arcpy from arcpy import env env.workspace = r"G:\desktop\gis" for mxd in arcpy.ListFiles("*.mxd"): mapdoc = arcpy....
4
votes
2answers
2k views

Importing modules in PyQGIS

I am trying to build a a library of scripts to call inside the QGis Python console/Python editior. I do not understand why they work independently, but not when being called from another script. ...
0
votes
1answer
136 views

NameError from using definition query in ArcPy?

I am having trouble getting my definition query to be defined. What am I missing? The current error is: Runtime error Traceback (most recent call last): File "<string>", line 44, in <...
2
votes
1answer
281 views

Setting globals in PyQGIS?

I'm working on this script in PyQGIS to take points from a layer called LEK_ALL and snap them to the closest feature of a line layer called LEID_filtered which fulfills a certain request. In order to ...
1
vote
1answer
53 views

Correct SQL expression for SelectbyAttribute Tool [duplicate]

I'm trying to apply the sql expression described here https://geonet.esri.com/thread/76028, that involves querying out odd values in a field. The specific sql expression is Round(NumberField / 2, 0) &...
2
votes
1answer
97 views

Cannot Import arcpy.mapping on ArcGIS

I can import arcpy and have been using ArcGIS Desktop, but in the tutorial I am following mxd = mapping.MapDocument("CURRENT") NameError: name 'mapping' is not defined This is frustrating because I ...
2
votes
1answer
175 views

Removing annotation layer according to data source using ArcPy gives NameError?

I work with this FGB annotation (ArcView 10.3): and i try to remove it with this code: import arcpy,os from arcpy import env env.workspace = r"G:\PROJECTS\road611\gis\aa" for mxdname in arcpy....
0
votes
2answers
142 views

Arcpy cannot locate rasters inside geodatabase

I've bunch of rasters inside a geodatabase and I'm trying to call them as inputs in a script, but I'm running into a strange problem. The script cannot find/locate these rasters, so I manually added ...
1
vote
0answers
52 views

NameError when attempting to auto increment field with python script [closed]

I am getting the following error when trying to run my code and I am not sure why: NameError: global name 'rec' is not defined Here is my code: field = "id_num" rec=0 def autoIncrement(): ...
1
vote
1answer
51 views

Getting NameError when using Cursors to read vertex coordinates in ArcPy? [closed]

I am new to python and having trouble Looping each feature in the new polygon shapefile, then use geometry cursors to read vertex coordinates of this lake polygon, identify the city that is the ...
3
votes
2answers
2k views

Global name "fc' not defined?

First, I'm trying to call a function from a module (final_functions) I created in a separate script. However I receive the following error: Traceback (most recent call last): File "C:\Python27\...
0
votes
2answers
580 views

ArcGIS tells me 'raster' isn't defined

I am trying to get zonal statistics for a set of geographical units for several years and I would like to get the output in one dbf table, where the rows mark the geographical units and each column is ...
0
votes
1answer
181 views

Getting NameError with PythEveryone in ArcGIS virtual campus module?

I'm working on the python for everyone lab in Esri's Virtual campus. I'm running into an issue that I can't seem to solve, I've already done some outside research hence posting here! The issue: 4th ...
0
votes
2answers
159 views

CellStatistics is not defined error

Code : >>> import arcpy >>> ras1 = arcpy.Raster(r'D:\IMD\test_converted1961.img') >>> ras2 = arcpy.Raster(r'D:\IMD\test_converted1961_fliped_ud1.img') >>> result = ...
10
votes
1answer
3k views

Adding PostGIS layer from QGIS Python plugin

I try to develop a plugin to add postgis layers to qgis from a plugin as part of learning python. The code for adding a postgis layer is taken from the cookbook and work fine if I run it from the ...
3
votes
1answer
914 views

Scripting with "self" in PyQGIS?

What is "self" and how can I use it error-free in a Q script? Example: mc = self.iface.mapCanvas() But when I try to run this in the Console I get the following error: NameError: name 'self' is ...
1
vote
1answer
169 views

NumPy Array to Feature Class: NameError from Inner Loop Variables

I have a NumPy Array to FC script that parses a JSON web-service. The outer loop writes to my FC correctly, however my inner loop variables come back as not defined when appending the items. The ...
3
votes
2answers
5k views

Error msg "Name is not defined" when trying to populate a field with the shape file name

I am trying to populate a field with corresponding file name. For example, if the file name is Route1.shp then the field value will be Route1 as well. However my code is not working. Can you please ...
1
vote
4answers
9k views

NameError: variable not defined even though set multiple times

This code original worked when run through the python command window in ArcCatalog. After I added the script to a toolbox I have had all sorts of troubles. The most frustrating error has been: ...
3
votes
3answers
2k views

Calculate field using variables as fields gives ERROR 000539?

When I calculate a field like this: field_0="field_name0" arcpy.CalculateField_management("Layer", field_0, '!field_name1! / !field_name2!', "PYTHON_9.3") It works! The field "field_name0" in the ...
1
vote
1answer
1k views

trouble with code block execution in python script

I am trying to calculate values for a field in a python script, but keep getting an error that I don't understand: ExecuteError: ERROR 000539: Error running expression: Fron000000F1 Traceback (most ...
0
votes
1answer
2k views

NameError: name 'QImage' is not defined [closed]

Traceback (most recent call last): File "<input>", line 1, in <module> File "F:/QGIS/bin/test.py", line 6, in <module> img = QImage(QSize(800,600), QImage....
10
votes
1answer
8k views

How to copy values from field to another using arcpy?

Can some one please let me know how I can do simple field calculation like Copying From "A" to "B" in ArcPy? I have found lots os example on web which they all used extra expression and they were ...
0
votes
1answer
5k views

NameError: name 'Con' is not defined

I have 365 rasters with the same extent, and I am trying to sum them together by month. I have the script below, which was working until I added the line out1 = Con(IsNull(raster), 0, raster) which is ...
0
votes
1answer
565 views

NameError: name 'finalPdf' is not defined

Could you please help me with this error: Traceback (most recent call last): File "C:\DDPeX\Export_GroupPDF.py", line 19, in finalPdf.appendPages(tempPdf) NameError: name 'finalPdf' is not ...
3
votes
2answers
1k views

How to control state of buttons in Python Add-In?

I have bunch of buttons to perform separate tasks within a Python Add-In. Buttons are greyed out and required to be enabled after initial tools run. In the following example, tool1 is turned off after ...
9
votes
1answer
3k views

Calling GRASS modules in pyQGIS?

I wish to use a Grass module (v.to.db) in QGis, without the grass toolbox. I tried with the Python console, but to no avail : Using Sextante plugin but obviously it didn't know all the grass modules. ...
6
votes
1answer
5k views

Performing Ordinary Kriging in SAGA via QGIS SEXTANTE Plug-in?

I'm trying to learn how to apply the kriging analysis in QGIS using the SEXTANTE plug-in and SAGA tools. It appears that I have my SEXTANTE and SAGA folders configured properly according to the user ...
2
votes
1answer
315 views

Using ArcObjects ITextSymbol.GetTextSize in Python to define two input variables that get populated by method

I am using Python 2.6 and ArcObjects in ArcGIS 10.0 to build and draw, among other things, graphic text on the current display. At one point I need to use the ITextSymbol.GetTextSize method. In a ...