Gi repository glib error



gi.repository.GLib.Error: gtk-builder-error-quark: No function named `btnProcess_clicked_cb`. (14)

I have .glade file written in glade ver. 3.38 and PyGObject 3.38. Right now I’m on Ubuntu 21.10 with PyGObject 3.40. So, I converting my glade from gtk3 to gtk4 with gtk4-builder-tool but i got an error gi.repository.GLib.Error: gtk-builder-error-quark: No function named btnProcess_clicked_cb. (14)

1 Answer 1

gtk_builder_connect_signals() no longer exists. Instead, signals are always connected automatically. If you need to add user data to your signals, gtk_builder_set_current_object() must be called. An important caveat is that you have to do this before loading any XML. This means if you need to use gtk_builder_set_current_object() , you can no longer use gtk_builder_new_from_file() , gtk_builder_new_from_resource() , or gtk_builder_new_from_string() . Instead, you must use vanilla gtk_builder_new() , then call gtk_builder_set_current_object() , then load the XML using gtk_builder_add_from_file() , gtk_builder_add_from_resource() , or gtk_builder_add_from_string() . You must check the return value for failure and manually abort with g_error() if something went wrong.

The easy way to use signals now, imo is Gtk.Template , you can look at the documentation here, https://pygobject.readthedocs.io/en/latest/guide/gtk_template.html

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.1.11.43147

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

ibus-setup: ModuleNotFoundError: No module named ‘gi’ #1984

Comments

AJNOURI commented Feb 20, 2018 •

Please fill in the following items if you don’t know the root cause.

Which distribution and version?:

Distributor ID: Debian
Description: Debian GNU/Linux 8.9 (jessie)
Release: 8.9
Codename: jessie

Which desktop environment and version?:

Which session type?:

Which application and version?:
(E.g. gedit 3.24, leafpad, kate, xterm)

IBus version?:
(Run ibus version )

Issue description:
Cannot configure ibus to add a new language neither from GUI nor CLI:

$ ibus-setup
Traceback (most recent call last):
File «/usr/share/ibus/setup/main.py», line 31, in
from gi.repository import GLib
ModuleNotFoundError: No module named ‘gi’

Steps to reproduce:

  1. «ibus-setup» fails
  2. «right click on ibus language icon > Preference» —> nothing happens

Can you reproduce your problem when you restart ibus-daemon? (yes / no):
(Run ibus exit and ibus-daemon —xim & )

$ ibus exit
$
(ibus-daemon:8662): GLib-WARNING **: GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). Most likely the process is ignoring SIGCHLD, or some other thread is invoking waitpid() with a nonpositive first argument; either behavior can break applications that use g_child_watch_add()/g_spawn_sync() either directly or indirectly.

[1]+ Done ibus-daemon —xim
$
$ ibus-daemon —xim &
[1] 8693
$
$ ibus-setup
Traceback (most recent call last):
File «/usr/share/ibus/setup/main.py», line 31, in
from gi.repository import GLib
ModuleNotFoundError: No module named ‘gi’

Do you see any errors when you run ibus-daemon with the verbose option?:
(Run ibus-daemon —xim —verbose & and look at the output when you encounter your problem.)

$ ibus-daemon —xim —verbose &
[1] 8762
$
(ibus-ui-gtk3:8767): IBUS-WARNING **: ibus_bus_call_sync: org.freedesktop.DBus.Properties.Get: GDBus.Error:org.freedesktop.DBus.Error.Failed: No global engine.

Can you reproduce your problem with a new user account instead of the current your account? (yes / no):

Tried to install python3-gi without success

$ sudo apt install python-gi python3-gi
Reading package lists. Done
Building dependency tree
Reading state information. Done
python-gi is already the newest version.
python3-gi is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 280 not upgraded.

The text was updated successfully, but these errors were encountered:

Источник

Gnome-terminal not starting due to error in python script related to GI

When I run gnome-terminal, I get the following error:

This looks odd to me, because the script is located in a python 3.4 installation but is calling print as if it was a python2 script (which is why the error occurs).

I tried to reinstall the package gi with pip3, but it keeps installing this version that looks like a python2 script.

My gnome-terminal points to /usr/bin/gnome-terminal, which is a python script that starts with #!/usr/bin/python3.

The lines with that particular error in init.py are:

This suggests a quick fix: putting parenthesis in those two print lines.

Which is strange.

This must be running on /usr/bin/python3, because that’s what on the shebang on /usr/bin/gnome-terminal.

python3 on the /usr/bin is actually a link to python3.4, which is a binary file.

I then run pip3 install gi and I get the following output, which tells me that actually gi is installed.

And right now I am out of ideas.

This started after I tried to install a Pumubuntu from https://github.com/Pumubuntu/Pumubuntu.

In the main script file it says:

So I thought I had to enter those commands. And that must have broken my gir installation (gir).

Can anybody help me?

6 Answers 6

Another way to fix this error that I found was to modify the gnome-terminal script located in /usr/bin/ and changing the environment (first line of the script) from #!/usr/bin/python3 to #!/usr/bin/python to switch from Python 3 to Python 2 as the Github command line is for Python 2 as noted in the previous answer.

Therefore, open up xterm by pushing the Super key (Key beside the bottom left Alt key) or by pushing Alt + F2 and typing in xterm to search for an alternative terminal and clicking on it to run. Next, type in sudo gedit /usr/bin/gnome-terminal , push ENTER and edit the first line in accordance to above. It’s not the best solution as you shouldn’t have to edit the script but it worked for me and it didn’t require uninstalling anything.

Update

The most current build of this requires Python 3, so as Jon M. in his comments stated, change the first line of the file to use Python 3.5:

Читайте также:  Error 1001 неизвестная ошибка 0x80005000

Источник

velovix / sunhacks_2020_gstreamer_talk.md

Hi everyone! Today I’m going to be giving you a crash course in video processing using Python. Coming out of this talk, you’ll be able to take video from pretty much any source, decode it, apply visual effects, and display it on-screen. To do this, we’re going to be using a library named GStreamer, an incredibly powerful and versatile framework. This is the same tool that the pros use, but don’t feel intimidated! GStreamer actually makes it very easy to do impressive things with video and you’ll be well on your way to making something great in just the time it takes to watch this talk.

If you fall behind at any point during the live presentation, don’t worry! I have a text version of this talk available with the same content and more. There should be a link in the description.

Let’s start by installing everything we’ll need to start using GStreamer in Python. This is probably the hardest part, so if you managed to do it before this talk, it’s all smooth sailing from here! If not, no worries! I’m going to go through how to install everything on Windows 10 right here. I would recommend opening up the text version of this talk, because I have links to the stuff we’ll be downloading and you’ll probably want to copy and paste a few of the long commands we’ll be running. If you’re using macOS or Linux, you’ll find separate instructions for how to install everything for those platforms there as well.

We’re going to be using a tool called MSYS2 to download everything we need to get started. MSYS2 makes it easy to set up development environments on Windows.

Download the latest stable release of MSYS2 from the releases page. At the time of writing, the latest release (2020-09-03) is available here. Then run the installer, accepting all the defaults, but unchecking «Run MSYS2».

Once it’s installed, start «MSYS2 MinGW 64-bit» from the Start Menu. This will open up the MSYS2 terminal.

Let’s get MSYS2 up-to-date by running the following command:

After this command finishes, it may need to close. Just open it right back up again!

Now, we’re ready to install everything we need! The following command installs GStreamer, some plugins, Python, and the PyGObject library.

Finally, you’re going to need a text editor to write code! I use Visual Studio Code but you can use whatever you like. Even Notepad is fine!

Homebrew, a package manager for macOS, makes it easy to install everything we need for this project. To install Homebrew, simply run the following command in the terminal:

Then, run this command to install everything we need:

Ubuntu, Debian, elementary OS, Pop!_OS

Installing everything we need on Ubuntu and related operating systems is easy! Just run the following command in the terminal:

Arch Linux, Manjaro

Like Ubuntu, installing everything on Arch Linux or Manjaro is just a matter of running the following command in the terminal:

Digital Video Concepts

While you’re waiting on everything to install, let’s take a step back. A wise scholar once said: Before you decode the video, you must understand the video. You must be the video.

At a fundamental level, video is presented to viewers as a list of images that are shown one after the other at a high enough speed for our eyes to see it as a moving picture. Pretty simple, right? Well, there’s just one problem. Storing all these thousands and thousands of images takes up a huge amount of space. An average 10 minute YouTube video would require over 100 GB of storage, and a feature-length movie could take upwards of a terabyte! Where is our escape from this madness??

Well, luckily, mathematicians and computer scientists have found many clever and sophisticated ways to compress video data down to a fraction of its original size. These researchers have turned their work into standards that define exactly how their technology works and how video data that is compressed this way can be decoded. We call these standards «video compression formats», and some popular ones include H.264, VP8, and AV1 among many others.

All the while, other smart people needed to figure out in what way the compressed video data should be saved to a video file, or split into chunks and streamed over the internet. This resulted in the development of special formats that hold both the compressed video data and additional information, like the title of the video, its resolution, and other stuff. We call these «container formats», and some popular ones include MPEG-4 and WebM.

So, in the end, you use a video camera to record something, those raw images get compressed in a video compression format, and once you’re done your video is wrapped up with a nice little bow using a container format. Now, the video file is ready to be stored on your computer or streamed out for all the world to see.

Now that we know how video works, we can begin to understand how GStreamer lets us work with it. Working with GStreamer is kind of like creating an assembly line in a factory. Each step in the assembly line is in charge of doing one thing, and the results of one step are passed on to the next step until the process is complete. GStreamer calls this assembly line a «pipeline», and the steps are known as «elements».

Читайте также:  Vba overflow error 6 это

Every pipeline starts with a source element, has some number of elements that process the data in the middle, and ends with a sink element. The source element is in charge of getting video data from somewhere, like a file on your computer or a video stream hosted online. That data is then passed to the next element, which does some processing on the data, and the result is passed on to the next element in the pipeline and so on. Finally, the fully processed data is passed to the sink element, which will take care of making the data available somewhere. That might involve saving it to your computer, hosting it as a live video stream, or passing it back to your application.

GStreamer has a lot of elements that do all kinds of different things. Each one has a name that we refer to it by, and certain rules governing what kinds of data it can take as input and what it produces as output.

Now, putting together one of these pipelines might sound hard, but GStreamer makes it pretty easy. All you have to do is give GStreamer a string with the names of each element you want in your pipeline, separated my exclamation marks. And that’s it! GStreamer will take care of creating these elements and attaching them to each other.

Let’s Get to the Code

With all that background in mind, let’s jump into the code. Now, we’re going to be writing in Python but the GStreamer library is written in C so we’re going to be using what’s called a «binding». A binding is simply a library that allows you to use a library in one language from another language. GStreamer’s Python binding library is called PyGObject, and we import it like this:

Now we need to tell PyGObject the minimum version of GStreamer that our program requires, which the library shortens to «Gst». Once we’ve done that, we’re ready to import the «Gst» module, as well as the «GLib» module which we will use shortly. Make sure to call Gst.init() to initialize GStreamer before doing anything else.

After that, we need to start the main loop. The main loop is in charge of handling events and doing some other background tasks. Here we’ll start it in a new thread, so that we can do other things in our main thread.

Finally, we’re ready to construct a simple pipeline! Like I mentioned earlier, all pipelines start with a source. Which source element we use will depend on where we want to get our video from. For now, let’s try getting video from our webcam. On Windows, we can use the ksvideosrc element to do his. If you’re on macOS, try autovideosrc . For Linux, it’s v4l2src .

Then, we’re going to follow that up with a decodebin element. This is a super helpful element that takes care of figuring out what container format and video compression format a source is providing, and handles decoding it for us into raw images.

Next let’s add a videoconvert element, another handy tool that takes care of any format differences between the images that decodebin provides and what our next element expects.

Our pipeline is almost done! Just like how every pipeline starts with a source, they also end with a sink! Our sink of choice today will be autovideosink , which will display our webcam footage on-screen.

We’ve defined our pipeline, but we’re not quite done yet! We still need to start the pipeline up. To do this, we use the set_state method, which asks the main loop that we started earlier to take care of initializing and playing our pipeline. All that work will be done in the background, so we can continue doing whatever we want in our program.

For this example, all we’re going to do is wait around while our webcam footage is being played on-screen until you stop the program. At that point, we’ll ask the pipeline to stop and clean up by setting it to the NULL state. Then, finally, we’ll stop the main loop we started earlier.

Here’s the example in full. Again, make sure to replace ksvideosrc with your platform’s equivalent if you’re not running on Windows.

Now that we’ve got our example application running, we can add some cool filters to our webcam stream! Some personal favorites of mine are edgetv and rippletv . Just make sure to add a videoconvert before and after them to ensure that the element is getting images in a format it’s compatible with.

Doing Your Own Thing with Video

GStreamer has a huge number of fun and useful elements for just about everything, but what if you wanted to do something custom? Maybe you want to implement your own special filter, or send the images off to another service or library. For these cases, GStreamer provides the appsink element, which allows you to take data out of the pipeline. Let’s check it out.

We’re going to use our original webcam pipeline, but replace the autovideosink with appsink . We’re going to give the element a name so that we can pull this element out of the pipeline and interact with it.

Now, we can pull images out of the appsink using the try_pull_sample method.

That’s all I’m going to show you about appsink in this talk, just to whet your appetite. But, I have some more examples in the text version of this talk if this sounds like something your hack needs.

Читайте также:  Missing return statement error in java

And.. that’s a wrap! Thanks so much for listening, and I hope you found it enjoyable. If you have any questions, please feel free to reach out to me on the sunhacks Discord. Again, my name is Tyler and I should be marked as a «mentor». Happy hacking!

My pipeline isn’t working. How do I find out why?

When GStreamer encounters a problem, it prints an error message to the console. However, by default, these logs are hidden. To see them, we need to set the GST_DEBUG environment variable.

For example, if you’re running your program like this:

Run it like this, instead:

However, reading GStreamer logs can sometimes feel like an art form. Feel free to reach out to me if you’re having trouble understanding what these logs are telling you!

nickcercone commented Feb 12, 2021

Great gist + video!!

I’m having trouble writing to disk using filesink. The file is on disk and has a sensible size in bytes but when I try to play it I get a no playable streams error. When I run the same gstreamer command in the command line everything works perfectly and the video is playable. I’m running Ubuntu on an Nvidia Jetson Nano.

Command line pipeline that works.

Python Gstreamer that works but produces no playable stream error when trying to play the video.

After googling I feel like it might have something to do with the -e flag you can add gst-launch-1.0 to force EOS end of stream on all sources before shutting a pipeline down but I am at a loss as to how I might try that with the python version.

Please share your wisdom!

velovix commented Feb 12, 2021

Hi! Perhaps your code is exiting before the pipeline has a chance to clean everything up. Let’s try waiting until the pipeline reaches the NULL state before quitting the main loop. Try adding this between the set_state call and main_loop.quit() :

nickcercone commented Feb 14, 2021

Thanks for the reply, the solution that worked for me was to add an EOS signal immediately before setting the state to null.

velovix commented Feb 16, 2021

Was this necessary even if you waited for the pipeline to come down?

saifurrehman4114 commented Mar 13, 2021

@nickcercone can you please tell me how to did you install gi module in Jetson Nano. I tried the above method but fail to run the above code.

ehHan commented Mar 18, 2021

First of all, thanks for your tutorial.
I’ve got the same successful result with MSYS!
Btw, there were some issues when I tried it with Anaconda.
I installed several packages like below

$ conda install -c conda-forge gstreamer
$ conda install -c conda-forge gst-plugins-base
$ conda install -c conda-forge gst-plugins-good
$ conda install -c conda-forge pygobject

and execute the same code but it says
gst_parse_error: no element «ksvideosrc» (1)

I guess it’s because there is no ‘gst-plugins-bad .’ // I guess I read it somewhere.

Instead, I tried it with ‘videotestsrc’
It seems working but it doesn’t give any screen window. (When I tried it with MSYS, it showed the default test screen.)

Do you have any idea about it?

velovix commented Mar 18, 2021

Could you try running your code with the GST_DEBUG environment variable set to 2 or higher and send me the logs? I’m guessing we’ll see an error of some kind.

Just a hunch, but if your pipeline looks like this: videotestsrc ! decodebin ! videoconvert ! autovideosink , you may want to try removing the decodebin element from the pipeline. videotestsrc produces raw video frames as output that don’t need to be decoded beforehand.

ehHan commented Mar 19, 2021

Thank you for your reply.
I removed ‘decodebin’ part but nothing changed.

And, I found something interesting with GST_DEBUG.

GST_DEBUG=2 python3 a1.py

It doesn’t work with the Anaconda command.
However, it works with the MSYS command.

So, I added two lines in the code:

0:00:00.089890000 13684 0000022839D7B2D0 ERROR GST_PIPELINE gst/parse/grammar.y:1121:priv_gst_parse_yyparse: specified empty bin «bin», not allowed
0:00:00.092168000 13684 0000022839D7B2D0 ERROR GST_PIPELINE gst/parse/grammar.y:938:priv_gst_parse_yyparse: link has no source [sink=@0000022839A0D840]
0:00:00.096156000 13684 0000022839D7B2D0 ERROR GST_PIPELINE gst/parse/grammar.y:1121:priv_gst_parse_yyparse: specified empty bin «bin», not allowed
0:01:11.301930000 13684 0000022839D7B2D0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:467:gst_element_factory_make: no such element factory «ksvideosrc»!
0:01:11.302488000 13684 0000022839D7B2D0 ERROR GST_PIPELINE gst/parse/grammar.y:850:priv_gst_parse_yyparse: no element «ksvideosrc»
0:01:11.302789000 13684 0000022839D7B2D0 ERROR GST_PIPELINE gst/parse/grammar.y:938:priv_gst_parse_yyparse: link has no source [sink=@0000022839A0FEC0]
0:01:33.381410000 13684 0000022839D7B2D0 WARN autodetect gstautodetect.c:351:gst_auto_detect_find_best: warning: Failed to find a usable video sink
0:01:33.382057000 13684 0000022839D4F940 FIXME default gstutils.c:4026:gst_pad_create_stream_id_internal:videotestsrc1:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:01:50.066782000 13684 0000022839D7B2D0 WARN autodetect gstautodetect.c:351:gst_auto_detect_find_best: warning: Failed to find a usable video sink
0:01:50.067396000 13684 0000022839D4F880 FIXME default gstutils.c:4026:gst_pad_create_stream_id_internal:videotestsrc2:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:02:02.276641000 13684 0000022839D7B2D0 WARN autodetect gstautodetect.c:351:gst_auto_detect_find_best: warning: Failed to find a usable video sink
0:02:02.277123000 13684 0000022839D4FB40 FIXME default gstutils.c:4026:gst_pad_create_stream_id_internal:videotestsrc3:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:02:36.614642000 13684 0000022839D7B2D0 WARN autodetect gstautodetect.c:351:gst_auto_detect_find_best: warning: Failed to find a usable video sink
0:02:36.615274000 13684 0000022839D4F8C0 FIXME default gstutils.c:4026:gst_pad_create_stream_id_internal:videotestsrc4:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:04:52.176123000 13684 0000022839D7B2D0 WARN autodetect gstautodetect.c:351:gst_auto_detect_find_best: warning: Failed to find a usable video sink
0:04:52.176671000 13684 0000022839D4FA40 FIXME default gstutils.c:4026:gst_pad_create_stream_id_internal:videotestsrc5:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id

I guess something is not installed properly?
Have you tried this example on Anaconda Env or any knowledge about it?

Источник

Оцените статью
toolgir.ru
Adblock
detector