AttributeError: 'MainRouter' object has no attribute '_disabled_count' - python

I am creating a kivy app where I have used router showing this error-
AttributeError: 'MainRouter' object has no attribute '_disabled_count'
Any solution?

I got this too but fixed it using super. Call the default init from within your new init using
super().__init__(**kwargs)

This error is caused by Kivy version. The latest version of Kivy-1.10.1 has some bug which is causing the problem. The older version seems fine!

Related

GTK Python gtk.TextBuffer(table=None) constructor error

I'm porting a Python GTK application from python2 to python3, using version 3.5.2. As part of this, I'm switching to updated GTK API calls. I need to call the gtk.TextBuffer constructor, described [here][1]. Following that documentation, I wrote:
tb = gtk.TextBuffer(table=text_tag_table)
This gives the following error:
*** TypeError: gobject `GtkTextBuffer' doesn't support property 'table'
I tried removing the table= part of the call:
gtk.TextBuffer(table=text_tag_table)
This gives:
*** TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
I can call the constructor without arguments, e.g., tb = gtk.TextBuffer(). I tried setting the tag table manually, like this:
tb.set_property("tag-table", text_tag_table)
This gives a warning:
__main__:1: Warning: g_object_set_property: construct property "tag-table" for object 'GtkTextBuffer' can't be set after construction
It seems like the original constructor with the table= arg should work. Can anyone help me figure out why it throws a TypeError? I did confirm using pydb that text_tag_table is an object of the correct type:
(Pdb) p text_tag_table
<Gtk.TextTagTable object at 0x7fb723d6b288 (GtkTextTagTable at 0x2b2e8e0)>
Thanks very much in advance!
The fix for this was to use the new method:
tb = gtk.TextBuffer.new(table=text_tag_table)
I'm a bit surprised that this works, but it seems fine!

Suppress warnings from Python module's destructor order

I am getting a series of warnings that occurs during interpreter shutdown of a Python 2.7 script when using libvirt. This is reproducible on a variety of distros including python2-libvirt 3.7.0-1 on Fedora 27 to libvirt-python 3.2.0-1 on Centos 7.4.1708. The warnings I get when the script is exitings is:
Exception AttributeError: "'NoneType' object has no attribute 'virDomainFree'" in <bound method virDomain.__del__ of <libvirt.virDomain object at 0x7f34a194ee10>> ignored
Exception AttributeError: "'NoneType' object has no attribute 'virDomainFree'" in <bound method virDomain.__del__ of <libvirt.virDomain object at 0x7f34a194ed90>> ignored
Exception AttributeError: "'NoneType' object has no attribute 'virConnectClose'" in <bound method virConnect.__del__ of <libvirt.virConnect object at 0x7f34a176a590>> ignored
Drilling down into the library, it seems to be an issue with assumptions in destructor order as in this code from libvirt.py:
class virDomain(object):
def __del__(self):
if self._o is not None:
libvirtmod.virDomainFree(self._o)
self._o = None
libvirtmod is a global created by an import at the top of the libvirt.py module. When the __del__() destructor for virDomain is finally run, libvirtmod has been replaced by the value None causing the code above to fail with a warning. We have been using this Python module for some time now, but only recently have these warning started showing up after we refactored the code quite heavily. What can I do to suppress these warnings from standard error or avoid the situation from occurring? Is there a way to ensure objects from libvirt.py are cleaned up before libvirtmod.so goes away?
We test on a variety of distros and would like to stick with using the stock (but updated) packages that come with the distro.
The standard trick is to equip __del__ with default arguments that hold whatever global values it needs (here, libvirtmod itself would suffice). There is a variation using weakref, which can also benefit from default arguments.

createDataFrame not working in Spark 2.0.0

I am trying to work through some of the examples in the new Spark 2.0 documentation. I am working in Jupyter Notebooks and command line. I can create a SparkSession with no problem. However when I try to create a dataframe I get the error of:
AttributeError: 'function' object has no attribute 'createDataFrame'
spark = SparkSession.builder.master("local").appName("Search").config(conf=SparkConf()).getOrCreate
d = [{'name': 'Alice', 'age': 1}]
spark.createDataFrame(d).collect()
Can someone please explain what I need to do to fix this error ? I have searched through the official documentation and not found anything on this particular error. Thank you.
getOrCreate is a method on SparkSession.Builder. You need to invoke it by adding the parentheses after:
spark = SparkSession.builder.master("local").appName("Search").config(conf=SparkConf()).getOrCreate()
See for more information: https://spark.apache.org/docs/2.0.1/api/java/org/apache/spark/sql/SparkSession.html
In general, the 'function' object has no attribute error is very common when you are accidentally referencing a function rather than invoking it.

mininet-wifi error:'Mininet' object has no attribute 'addBaseStation'

When I execute my Python script using mininet-wifi, I am getting the following error, and I don't know why?
error:'Mininet' object has no attribute 'addBaseStation'
Should I change addBaseStation into addAcessPoint? If so, what is the difference between these?
Try out addAccessPoint() instead.

geom_dotplot in rpy2?

When I try to use gplot2.geom_dotplot I get the error:
AttributeError: 'module' object has no attribute 'geom_dotplot'
Does this function have a different name in Rpy2? thanks.
The mapping of that function is just missing. This is a bug with rpy2. The fix will in the repository shortly (will be released with version 2.3.4).
In the meantime a workaround can be to add the following to your code.:
from rpy2.robjects.lib import ggplot2
class GeomDotplot(ggplot2.Geom):
_constructor = ggplot2.ggplot2_env['geom_dotplot']
ggplot2.geom_dotplot = GeomDotplot.new

Categories