error when starting spyder on ubuntu 22.04 - qt

I have just upgrade my ubuntu. I have this error on spyder:
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Traceback (most recent call last):
File "/usr/bin/spyder", line 33, in <module>
sys.exit(load_entry_point('spyder==4.2.1', 'gui_scripts', 'spyder')())
File "/usr/lib/python3/dist-packages/spyder/app/start.py", line 213, in main
mainwindow.main(options, args)
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3624, in main
mainwindow = create_window(app, splash, options, args)
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3482, in create_window
main.setup()
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 803, in setup
self.completions = CompletionManager(self)
File "/usr/lib/python3/dist-packages/spyder/plugins/completion/plugin.py", line 97, in __init__
plugin_client = Plugin(self.main)
File "/usr/lib/python3/dist-packages/spyder/plugins/completion/kite/plugin.py", line 50, in __init__
self.installer = KiteInstallerDialog(
File "/usr/lib/python3/dist-packages/spyder/plugins/completion/kite/widgets/install.py", line 287, in __init__
self._integration_widget = KiteIntegrationInfo(self)
File "/usr/lib/python3/dist-packages/spyder/plugins/completion/kite/widgets/install.py", line 58, in __init__
image = image.scaled(image_width, image_height, Qt.KeepAspectRatio,
TypeError: arguments did not match any overloaded call:
scaled(self, int, int, aspectRatioMode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio, transformMode: Qt.TransformationMode = Qt.FastTransformation): argument 1 has unexpected type 'float'
scaled(self, QSize, aspectRatioMode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio, transformMode: Qt.TransformationMode = Qt.FastTransformation): argument 1 has unexpected type 'float'
All the solution that I have found deal with specific application developed my different user and not for probel related to upgrade or ubuntu.

As a quick workaround just comment out the lines in File:
/usr/lib/python3/dist-packages/spyder/plugins/completion/kite/widgets/install.py
58
#image = image.scaled(image_width, image_height, Qt.KeepAspectRatio, Qt.SmoothTransformation)
143
#install_gif.setScaledSize(QSize(image_width, image_height))
244-247
#copilot_label.setPixmap(
# copilot_image.scaled(image_width, image_height,
# Qt.KeepAspectRatio,
# Qt.SmoothTransformation))

(Spyder maintainer here) The Spyder package provided by Ubuntu 22.04 (4.2.1, released in December 2020) is broken with the Python version that comes with it (3.10).
However, this error was fixed in any Spyder version released after 5.3.0, released in March 2022. So, to solve this problem please uninstall the Spyder that comes with Ubuntu and install it with pip in a virtualenv, as explained in our documentation.

I had the exact same problem, did a search with the following two items :
"spyder" + "mainwindow.py, line 3624" # aka a piece of the error message
I found the bug report #16571 on spyder's github : "TypeError in Tour with Python 3.10", which identified python 3.10 as the culprit.
In Debian + aptitude I downgraded python 3 from 3.10 to the 3.9 version, launched Spyder again and...problem solved !

Related

exception while running bitbake

taking my first steps in BitBake using this guide, setup works fine until the point when i run bitbake world, where i get this -
WARNING: python should use 4 spaces indentation, but found tabs in base.bbclass, line 41
....
WARNING: python should use 4 spaces indentation, but found tabs in base.bbclass, line 64
Parsing recipes: 100% |###########################################################################################################################################################################| Time: 0:00:00
Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
ERROR: An uncaught exception occurred in runqueue################################################### | ETA: 0:00:00
Traceback (most recent call last):
File "/home/ubuntu/bitbake/lib/bb/runqueue.py", line 1508, in RunQueue.execute_runqueue():
try:
> return self._execute_runqueue()
except bb.runqueue.TaskFailure:
File "/home/ubuntu/bitbake/lib/bb/runqueue.py", line 1428, in RunQueue._execute_runqueue():
[43, 967, 4, 3, 1, 5, 3, 7, 13, 1, 2, 1, 1, 246, 35, 1, 38, 1, 35, 2, 338, 204, 142, 3, 3, 37, 244])
> if self.rqdata.prepare() == 0:
self.state = runQueueComplete
File "/home/ubuntu/bitbake/lib/bb/runqueue.py", line 1164, in RunQueueData.prepare():
todeal.remove(tid)
> self.prepare_task_hash(tid)
File "/home/ubuntu/bitbake/lib/bb/runqueue.py", line 1177, in RunQueueData.prepare_task_hash(tid='/home/ubuntu/Poky/poky/meta-tutorial/recipes-tutorial/first/first_0.1.bb:do_build'):
self.runtaskentries[tid].hash = bb.parse.siggen.get_taskhash(taskfn, taskname, procdep, self.dataCaches[mc])
> self.runtaskentries[tid].unihash = bb.parse.siggen.get_unihash(taskfn + "." + taskname)
File "/home/ubuntu/bitbake/lib/bb/siggen.py", line 45, in SignatureGenerator.get_unihash(task='/home/ubuntu/Poky/poky/meta-tutorial/recipes-tutorial/first/first_0.1.bb.do_build'):
def get_unihash(self, task):
> return self.taskhash[task]
KeyError: '/home/ubuntu/Poky/poky/meta-tutorial/recipes-tutorial/first/first_0.1.bb.do_build'
Summary: There were 13 WARNING messages shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
and yes - i pulled the latest BitBake from github:
bitbake --version
BitBake Build Tool Core version 1.40.0
what's wrong with my python code?
https://www.yoctoproject.org/docs/2.1/bitbake-user-manual/bitbake-user-manual.html#var-BB_SIGNATURE_HANDLER
It seems using BB_SIGNATURE_HANDLER noop(by default)
I fix this error by adding BB_SIGNATURE_HANDLER define in meta-tutorial/conf/bitbake.conf
BB_SIGNATURE_HANDLER ?= "basichash"
I am facing exactly the same issue, finally found it due to bitbake version.
If you git clone bitbake from https://github.com/openembedded/bitbake, you could checkout to a early version:
git checkout tags/1.26.0 -b 1.26.0
Then the issue is gone.
The tutorial code is broken. The bitbake.conf is stored in
ch04/meta-tutorial/conf/bitbake.conf
but it belongs to
ch04/build/conf/bitbake.conf
Move the file there and it works
I opened an issue: https://bitbucket.org/a4z/bitbakeguide/issues/17/bitbakeconf-stored-in-the-wrong-place

Error in pyomo expression generation with sum using python 3.6

I am using pyomo Pyomo 5.1.1 (CPython 3.6.0 on Linux 3.16.0-4-amd64)
under Python 3.6, and I get an error message when I want to build an Expression in a model using a summation.
Here is a minimal example :
from pyomo.environ import *
from pyomo.opt import SolverFactory
model=ConcreteModel()
model.H=RangeSet(0,23)
model.x=Var(model.H)
E=summation(model.x)
I get the following error :
"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/util.py", line 86, in summation
ans += item
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/numvalue.py", line 537, in __iadd__
return generate_expression(_iadd,self,other)
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/expr_coopr3.py", line 977, in generate_expression
_self = _generate_expression__clone_if_needed(_self, 1)
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/expr_coopr3.py", line 918, in _generate_expression__clone_if_needed
% ( getrefcount(obj) - UNREFERENCED_EXPR_COUNT, ))
RuntimeError: Expression entered generate_expression() with too few references (0<0); this is indicative of a SERIOUS ERROR in the expression reuse detection scheme.
"
I get the same error if I replaced the "summation" by a loop over h in model.H.
The bug has been noticed also here : https://github.com/Pyomo/pyomo/issues/103
Is there a simple way to fix this, other than stepping back to older version of Python ?
Thank you very much for your help,
Paulin
Pyomo only supports Python 2.6, 2.7, 3.3, 3.4, and 3.5.
Python 3.6 changed the internal call stack, which invalidated the internal "magic numbers" that Pyomo uses for detecting when an expression is being pointed to by extra variables (i.e., it is potentially being reused in multiple expressions - something that is not allowed by the Pyomo expression trees). The developers are working on a fix (in the pyomo4-expressions branch). Until that fix is merged back into master and released, the only alternative is to install one of the supported Python versions.
Update [3 April 17]: The fix was merged back into master on 7 March 2017. Pyomo should support Python 3.6 in the next patch release.
Update [14 May 17]: Pyomo 5.2 has been released, which provides full support for Python 3.6

Unexpected error reading GML graph

I have downloaded the gml file which contains the dolphins social network.
Some time ago I did some analysis on that network running python 3.4 and networkx 1.9 on a a Windows7 machine, but now I am running on a Arch linux machine (with the same version of python but with networkx 1.10) and found an issue when tried to read the file.
This is the code used to read the file:
import networkx as nx
nx.read_gml("dolphins.gml")
And this is the stack trace of the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2, in read_gml
File "/usr/lib/python3.4/site-packages/networkx/utils/decorators.py",line 220, in _open_file
result = func(*new_args, **kwargs)
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 210, in read_gml
G = parse_gml_lines(filter_lines(path), label, destringizer)
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 383, in parse_gml_lines
graph = parse_graph()
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 372, in parse_graph
curr_token, dct = parse_kv(next(tokens))
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 323, in tokenize
(line[pos:], lineno + 1, pos + 1))
networkx.exception.NetworkXError: cannot tokenize 'graph' at (1, 1)
Are you able to read the file? Someone has experienced a simmilar issue? or knows what is generating the error?
Thank you in advance!
In the newer versions of networkx, the gml file should follow a more specific format. The problem with the dolphins.gml is that there should not be any carriage return before the open square brackets. For example:
Wrong format:
graph
[
directed 0
node
[
id 0
label "Beak"
]
.
.
.
Correct format:
graph [
directed 0
node [
id 0
label "Beak"
]
.
.
.
It does not care about how many spaces there are before the square bracket as long as there is more than one and there is no carriage return.
What I ended up doing was using regular expression to get rid of the white spaces before the opening square brackets. The following regex worked for me:
\s+\[
and just replace it with " [". There has to be at least one space before the bracket.
Also keep in mind that every node has to have a unique label.
Hope it helped.
It worked by downgrading the networkx version from 1.10 to 1.9.1.
Hope this answer can help someone else.

How can I overcome this key word error?

enter code here
# -*- coding: utf-8 -*-
import math
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig1=plt.figure()
ax=plt.axes(xlim=(-10,10), ylim=(-10,10))
line,=ax.plot([],[],lw=1)
"""def init ():
line.set_data([],[])
return line,"""
dt=0.001
X=[]
Y=[]
r=float(input("Enter the radius :: "))
w=float(input("Enter angular frequency :: "))
def run(data):
t=0
while w*t<=2*math.pi:
x=r*math.cos(w*t)
y=r*math.sin(w*t)
X.append(x)
Y.append(y)
t=t+dt
line.set_data(X,Y)
return line,
line,=ax.plot(X,Y,lw=2)
FFMpegWriter = animation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'), bitrate=1800)
anim=animation.FuncAnimation(fig1,run,frames=200,interval=20,blit=True)
anim.save('amim.mp4',writer=writer)
The error message shown is ::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tathagata/anaconda3/lib/python3.4/site- packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/home/tathagata/anaconda3/lib/python3.4/site- packages/spyderlib/widgets/externalshell/sitecustomize.py", line 85, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/home/tathagata/Documents/Python scripts/circleamim.py", line 35, in <module>
FFMpegWriter = animation.writers['ffmpeg']
File "/home/tathagata/anaconda3/lib/python3.4/site-packages/matplotlib/animation.py", line 81, in __getitem__
return self.avail[name]
KeyError: 'ffmpeg'
I use anacoda distribution and SPYDER as my IDE. I have seen the many solutions related to key errors. But the movie wont run. How can I make the movie to run? I hope there are no other logical errors.
First install ffmpeg and add path to ffmpeg
# on windows
plt.rcParams['animation.ffmpeg_path'] = 'C:\\ffmpeg\\bin\\ffmpeg.exe'
# on linux
plt.rcParams['animation.ffmpeg_path'] = u'/home/username/anaconda/envs/env_name/bin/ffmpeg'
Note for linux users: The path for ffmpeg can be found by simply using which: which ffmpeg
Also instead of
FFMpegWriter = animation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'), bitrate=1800)
I just used writer = animation.FFMpegWriter()
It seems that ffmpegis not installed on your system. Try the following code:
import matplotlib.animation as animation
print(animation.writers.list())
It will print out a list of all available MovieWriters. If ffmpegis not among it, you need to install it first from the ffmpeg homepage.
If you have Homebrew, literally just run the command
brew install ffmpeg
And Homebrew will take care of the rest (dependencies, etc). If you don't, I would recommend getting Homebrew or something like it (apt-get on Linux is built in, or an alternative on OS X would be Macports)
I have also posed with same problem(keyError: 'ffmpeg') but instead of using anakonda, I used IDLE3. So, first i checked for 'ffmpeg' in terminal it wasn't installed so installed it.
Using: sudo apt install ffmpeg
and when I run my save_animation program, it worked generating animation files in '.mpeg' format.

IPython notebook and rmagic/rpy2: cannot find module ri2py (OSX 10.8.5, python 2.7, R 3.1)

I'm trying to use the rmagic extension for the IPython notebook, using Python 2.7.6 via Enthought Canopy.
When I try the following example:
import numpy as np
import pylab
X = np.array([0,1,2,3,4])
Y = np.array([3,5,4,6,7])
pylab.scatter(X, Y)
%Rpush X Y
%R lm(Y~X)$coef
I get an error:
AttributeError Traceback (most recent call last)
<ipython-input-7-96dff2c70ba0> in <module>()
1 get_ipython().magic(u'Rpush X Y')
----> 2 get_ipython().magic(u'R lm(Y~X)$coef')
…
/Users/hrob/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/extensions/rmagic.pyc in eval(self, line)
212 res = ro.r("withVisible({%s})" % line)
213 value = res[0] #value (R object)
--> 214 visible = ro.conversion.ri2py(res[1])[0] #visible (boolean)
215 except (ri.RRuntimeError, ValueError) as exception:
216 warning_or_other_msg = self.flush() # otherwise next return seems to have copy of error
AttributeError: 'module' object has no attribute 'ri2py'
I can't find anyone else who's had the same problem and don't know enough to solve it myself. There is no definition for ri2py in conversion.py though.
I initially had installed Anaconda and was running python notebook through that, with exactly the same results.
rpy2 (version 2.4.0) installed successfully but when I test it I get 1 expected failure as follows:
python -m 'rpy2.robjects.tests.__init__'
…
testNewWithTranslation (testFunction.SignatureTranslatedFunctionTestCase) ... expected failure
I don't know if that's related.
Can anyone suggest what the problem might be and how I might fix it? Are the versions of python, R, etc. that I'm using compatible or do I need to re-install/update something?
Are you using %load_ext rmagic?
If so, try using %load_ext rpy2.ipython instead.
This is one of the new features in version 2.4.0.

Resources