when setting WA_DeleteOnClose attribute on PYQT6 MDI subwindow , there is a no attribute error - pyqt5

subwindow = QMdiSubWindow()
self.subwin = CollectInfo()
subwindow.setWidget(self.subwin)
subwindow.setAttribute(Qt.WA_DeleteOnClose)
self.mdiArea.addSubWindow(subwindow)
subwindow.showMaximized()
there is the exception:
Connected to pydev debugger (build 223.8617.48)
Traceback (most recent call last):
File "D:\Python\NetAuto\main.py", line 60, in add_subwindow
subwindow.setAttribute(Qt.WA_DeleteOnClose)
AttributeError: type object 'Qt' has no attribute 'WA_DeleteOnClose'
python-BaseException

Related

Is there a way to fix AttributeError: module 'tensorflow._api.v2.io.gfile' has no attribute 'Open'

ERROR: test_create_center_net_model_mobilenet (main.ModelBuilderTF2Test)
ModelBuilderTF2Test.test_create_center_net_model_mobilenet
Test building a CenterNet model using bilinear interpolation.
Traceback (most recent call last):
File "Tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py", line 499, in test_create_center_net_model_mobilenet
self.get_fake_label_map_file_path())
File "Tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py", line 80, in get_fake_label_map_file_path
with tf.io.gfile.Open(keypoint_label_map_path, 'wb') as f:
AttributeError: module 'tensorflow._api.v2.io.gfile' has no attribute 'Open'

<TypeError: loop of ufunc does not support argument 0 of type numpy.ndarray which has no callable rint method

I get the followin error when I tey tu run the file from terminal:
I am using python 3.7 and working on a windows 10 system.
The error apears while running a virtual environment where all the requirements have been installed.
Using TensorFlow backend.
AttributeError: 'numpy.ndarray' object has no attribute 'rint'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\52331\PycharmProjects\Q-Learning-for-Trading\venv\lib\site-packages\numpy\core\fromnumeric.py", line 61, in _wrapfunc
return bound(*args, **kwds)
TypeError: loop of ufunc does not support argument 0 of type numpy.ndarray which has no callable rint method
During handling of the above exception, another exception occurred:
AttributeError: 'numpy.ndarray' object has no attribute 'rint'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "run.py", line 29, in <module>
data = np.around(get_data())
File "<__array_function__ internals>", line 6, in around
File "C:\Users\52331\PycharmProjects\Q-Learning-for-Trading\venv\lib\site-packages\numpy\core\fromnumeric.py", line 3224, in around
return _wrapfunc(a, 'round', decimals=decimals, out=out)
File "C:\Users\52331\PycharmProjects\Q-Learning-for-Trading\venv\lib\site-packages\numpy\core\fromnumeric.py", line 70, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "C:\Users\52331\PycharmProjects\Q-Learning-for-Trading\venv\lib\site-packages\numpy\core\fromnumeric.py", line 47, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
TypeError: loop of ufunc does not support argument 0 of type numpy.ndarray which has no callable rint method

"Error in sys.excepthook" PyQt5.10.1Python 3.6

i have a custom sys.excepthook in my main.py:
def application_exception_hook(type_, value, tb):
lines = format_exception(type_, value, tb)
for line in lines:
print(line)
sys.excepthook = sys._excepthook
sys.exit(1)
sys._excepthook = sys.excepthook
sys.excepthook = application_exception_hook
In case of a unhandled exception the console output is:
Traceback (most recent call last):
Error in sys.excepthook:
Traceback (most recent call last):
Original exception was:
Traceback (most recent call last):
Replacing...
for line in lines:
print(line)
...with...
print(lines)
...gives me this output:
['Traceback (most recent call last):\n', ' File "D:\\...\\framework.py", line 144, in openNesting\n foo = 123 / 0\n', 'ZeroDivisionError: division by zero\n']Error in sys.excepthook:
Traceback (most recent call last):
Original exception was:
Traceback (most recent call last):
So, in both cases there is an "Error in sys.excepthook", while in the first case the error already appears before printing out all the interesting attributes. I would like to know what could cause "Error in sys.excepthook" and how I can get ONLY this output:
Traceback (most recent call last):
File "D:\\...\\framework.py", line 144, in openNesting
foo = 123 / 0
ZeroDivisionError: division by zero
I could not find any solved topic adressing this specific problem.
Solved: There was an error in a method that duplicates stdout and stderr messages to a QtTextEdit. After manually tracing it down everything now works as expected.

Numpy error in hmmlearn

I am using hmmlearn library to create HMM. While running the code it gave an error ttributeError: 'module' object has no attribute 'broadcast_to'.
I am running GMMHMM as
model1 = GMMHMM(n_components=4, n_mix=64, covariance_type='diag', n_iter=1000, min_covar=0.001, startprob_prior=1.0, transmat_prior=1.0, weights_prior=1.0, means_prior=0.0, means_weight=0.0, covars_prior=None, covars_weight=None, algorithm='viterbi', random_state=None, tol=0.01, verbose=False, params='stmcw', init_params='stmcw').fit(X)
and the error traceback is
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-i686/egg/hmmlearn/base.py", line 424, in fit
File "build/bdist.linux-i686/egg/hmmlearn/hmm.py", line 609, in _init
File "build/bdist.linux-i686/egg/hmmlearn/hmm.py", line 677, in
_fix_priors_shape
AttributeError: 'module' object has no attribute 'broadcast_to'
I figured out that it is because of numpy. How can we fix this
Make sure you have at least NumPy 1.10.0, because np.broadcast_to is not available for newer versions.

FeedparserDict object doesn't have 'content' attribute

I am trying to get familiar with the feedparser library, but I don't seem to be able to access the content attribute of entries in the feedparser object:
d = feedparser.parse('http://www.reddit.com/r/python/.rss')
post = d.entries[2]
post.content
the above code block gives me this error:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\feedparser.py", line 414, in __getattr__
return self.__getitem__(key)
File "C:\Python34\lib\site-packages\feedparser.py", line 375, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'content'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
content = post.content[0].value
File "C:\Python34\lib\site-packages\feedparser.py", line 416, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'content'
Just do a print(post) and you will probably see that it doesn't have a content attribute.
RSS feeds do not guarantee that it will have one.