AttributeError: DescribeData: Method shapeFieldName does not exist - visual-studio

skipFlds = [desc.shapeFieldName, desc.OIDFieldName]
Error: AtrributeError: DescribeData: Method shapeFieldName does not exist

That error is common when a shape/geometry field doesn't exist, like in a regular table. Double check you are describing a spatial dataset; if so, then the dataset may be corrupted and ArcPy isn't recognizing a spatial data type exists.
>>> import arcpy
>>>
>>> fc = # path to feature class
>>> tbl = # path to table
>>>
>>> desc_fc = arcpy.Describe(fc)
>>> desc_fc.shapeFieldName
'Shape'
>>>
>>> desc_tbl = arcpy.Describe(tbl)
>>> desc_tbl.shapeFieldName
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: DescribeData: Method shapeFieldName does not exist
>>>

Related

how to display image from a column in sqlite database

i am developing a dictionary that display meaning and image of a word at the same time when the word is being searched.I want to display image from a column on a table in sqlite database but it is giving me error
def search(event=''):
conn = sqlite3.connect('G_DICTION.db')
cur = conn.cursor()
tex.delete(1.0, "end")
data = v.get()
cur.execute("SELECT Meaning, Image FROM DICTION WHERE Words= ?", (data,))
var = cur.fetchone()
if var:
tex.insert("end", var[0]) # accessing the meaning
else:
messagebox.showinfo("Dic", "Word not found")
#####################################
img_path = var[1] # accessing the path to the image
image_object = tk.PhotoImage(img_path) # here I'm not using PIL, but tkinter PhotoImage
ImageLabel.config(image=image_object)
ImageLabel.image = image_object
frame = tk.Frame(dictWin)
frame.place(x=50, y=395)
ImageLabel = tk.Label(frame, font=("calibra", 9), bg="white")
ImageLabel.pack(expand=True, fill=tk.BOTH, padx=65, pady=20)
this is the error below;
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705,
in __call__
return self.func(*args)
File "C:\Users\Temmy\.PyCharmEdu2019.1\config\scratches\newdatba.py", line 23, in search
ImageLabel.config(image=image_object)
NameError: name 'ImageLabel' is not defined
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705,
in __call__
return self.func(*args)
File "C:\Users\Temmy\.PyCharmEdu2019.1\config\scratches\newdatba.py", line 23, in search
ImageLabel.config(image=image_object)
NameError: name 'ImageLabel' is not defined

'DataFrame' object has no attribute 'split_frame'

Unable to Split frame using split_frame(). The dataframe is able to show() but I cannot split it. Please help.
Below is a sample of the code I have used.
from h2o.estimators.random_forest import H2ORandomForestEstimator
from h2o.estimators.gbm import H2OGradientBoostingEstimator
from h2o.estimators.deeplearning import H2ODeepLearningEstimator
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
from __future__ import print_function
temp = spark.read.option("header","true").option("inferSchema","true").csv("hdfs://bda-ns/user/august_week2.csv")
train,test,valid = temp.split_frame(ratios=[.75, .15])
Expected: no error. Data split into test and train data frame.
Actual:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/cloudera/parcels/SPARK2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101/lib/spark2/python/pyspark/sql/dataframe.py", line 1182, in __getattr__
"'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'DataFrame' object has no attribute 'split_frame'
>>> train,test,valid = temp.split_frame(ratios=[.75, .15])
Traceback (most recent call last):
File "/opt/cloudera/parcels/SPARK2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101/lib/spark2/python/pyspark/context.py", line 234, in signal_handler
You could use randomsplit on your spark dataframe.
If you want to use the H2O-3 split_frame method, you would first have to convert your spark frame to an h2o frame. In which case you could use hc.as_h2o_frame(spark_df) where hc is your h2o_context (note: you would also need to create the h2o_context for this to work).

FileNotFoundError: No such file: 'someones_epi.nii.gzip'

I am trying to load an MRI, I keep getting the following error:
Traceback (most recent call last):
File "F:/Study/Projects/BTSaG/Programs/t3.py", line 2, in <module> epi_img = nib.load('someones_epi.nii.gzip')
File "C:\Users\AnkitaShinde\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nibabel\loadsave.py", line 38, in load raise FileNotFoundError("No such file: '%s'" % filename)
FileNotFoundError: No such file: 'someones_epi.nii.gzip'
The code is used is as follows:
import nibabel as nib
epi_img = nib.load('someones_epi.nii.gzip')
epi_img_data = epi_img.get_data()
epi_img_data.shape(53, 61, 33)
import matplotlib.pyplot as plt
def show_slices(slices):
""" Function to display row of image slices """
fig, axes = plt.subplots(1, len(slices))
for i, slice in enumerate(slices):
axes[i].imshow(slice.T, cmap="gray", origin="lower")
slice_0 = epi_img_data[26, :, :]
slice_1 = epi_img_data[:, 30, :]
slice_2 = epi_img_data[:, :, 16]
show_slices([slice_0, slice_1, slice_2])
plt.suptitle("Center slices for EPI image")
I have also updated the loadsave.py file in nibabel but it didn't work. Please help.
Edit:
The earlier error was resolved. Now another error has been encountered.
Traceback (most recent call last):File "F:\Study\Projects\BTSaG\Programs\t3.py", line 2, in <module> epi_img = nib.load('someones_epi.nii.gzip')
File "C:\Users\AnkitaShinde\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nibabel\loadsave.py", line 47, in load filename)
nibabel.filebasedimages.ImageFileError: Cannot work out file type of "someones_epi.nii.gzip"
This is an old question, however I may have the solution for it.
I just figured out that nibabel.save() does not allow me to have dot . or dash - in the folder names. These can exist in filenames however. In your case, the current path is:
C:\Users\AnkitaShinde\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\nibabel\someones_epi.nii.gzip
I would change it to:
C:\Users\AnkitaShinde\AppData\Local\Programs\Python\Python35_32\Lib\site_packages\nibabel\someones_epi.nii.gzip
This is just to give an example. Of course, I don't mean that you actually change the names of these package folders as it might cause other errors.
The actual solution would be to move the file someones_epi.nii.gzip to the user structure, something like:
C:\Users\AnkitaShinde\Desktop\nibabel\someones_epi.nii.gzip

How to know MRO in python2

In python3, we can use '__mro__' to get the method-resolution-order like below:
>>> class a:
... pass
...
>>> a.__mro__
(<class '__main__.a'>, <class 'object'>)
>>>
Does python2 has an alternative method for this? I tried to find one but failed.
>>> class a:
... pass
...
>>> dir(a)
['__doc__', '__module__']
>>> class a(object):
... pass
...
>>> dir(a)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
mro() is available since Python 2.2 (https://www.python.org/download/releases/2.3/mro/)
However the class must be a new style class.
>>> class A: pass
>>> A.mro()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: class A has no attribute 'mro'
>>> class A(object): pass
>>> A.mro()
[<class '__main__.A'>, <type 'object'>]

PyQt5 Signals and Slots 'QObject has no attribute' error

I have been trying to find a way to update the GUI thread from a Python thread outside of main. The PyQt5 docs on sourceforge have good instructions on how to do this. But I still can't get things to work.
Is there a good way to explain the following output from an interactive session? Shouldn't there be a way to call the emit method on these objects?
>>> from PyQt5.QtCore import QObject, pyqtSignal
>>> obj = QObject()
>>> sig = pyqtSignal()
>>> obj.emit(sig)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'emit'
and
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'sig'
and
>>> obj.sig = pyqtSignal()
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'PyQt5.QtCore.pyqtSignal' object has no attribute 'emit'
Following words and codes are in PyQt5 docs.
New signals should only be defined in sub-classes of QObject.They must be part of the class definition and cannot be dynamically added as class attributes after the class has been defined.
from PyQt5.QtCore import QObject, pyqtSignal
class Foo(QObject):
# Define a new signal called 'trigger' that has no arguments.
trigger = pyqtSignal()
def connect_and_emit_trigger(self):
# Connect the trigger signal to a slot.
self.trigger.connect(self.handle_trigger)
# Emit the signal.
self.trigger.emit()
def handle_trigger(self):
# Show that the slot has been called.
print "trigger signal received"

Resources