Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:14:42+00:00 2026-06-08T09:14:42+00:00

When importing pynotify I always get those nasty GTK-Warnings: ** (process:25512): WARNING **: Trying

  • 0

When importing pynotify I always get those nasty GTK-Warnings:

** (process:25512): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'

The problem is, I don’t know how to suppress them, I tried:

>>> import sys
>>> from io import BytesIO
>>> sys.stderr = BytesIO()
>>> sys.stdout = BytesIO()
>>> print 's'
>>> import pynotify

** (process:25512): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

** (process:25512): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

** (process:25512): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'

Doesn’t work, another thing I tried:

with warnings.catch_warnings():
    warnings.simplefilter('error')
    import pynotify

This also doesn’t help.

Seems like the GTK messages arrive on a different stderr. Any ideas how to suppress them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:14:44+00:00Added an answer on June 8, 2026 at 9:14 am

    To suppress these messages, you need to redirect stderr via its file descriptor:

    import os
    from contextlib import contextmanager
    
    @contextmanager
    def suppress_output(fd):
        """
        Suppress output to the given ``fd``::
    
           with suppress_fd(sys.stderr):
               # in this block any output to standard error is suppressed
    
        ``fd`` is an integral file descriptor, or any object with a ``fileno()``
        method.
        """
        if hasattr(fd, 'fileno'):
            # we were given a file-like object with an underlying fd
            if hasattr(fd, 'flush'):
                # flush Python-side buffers before redirecting
                fd.flush()
            # get the fd to redirect
            fd = fd.fileno()
    
        # duplicate the file descriptor to restore it eventually
        oldfd = os.dup(fd)
        try:
            # open the trash can
            devnull = os.open(os.devnull, os.O_WRONLY)
            try:
                # point the file descriptor to the trash can
                os.dup2(devnull, fd)
            finally:
                # close the old trash can descriptor, we don't need it anymore
                # since the fd now points to the trash can
                os.close(devnull)
            # enter the callers block
            yield
            # restore the file descriptor
            os.dup2(oldfd, fd)
        finally:
            # close the duplicated copy of the original fd, we don't need it
            # anymore now that fd is restored
            os.close(oldfd)
    

    Use of this function is as simple as:

    import sys
    
    with suppress_output(sys.stderr):
        import pynotify
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Upon importing the JSONKit.h and JSONKit.m files into my project , i get the
Importing parts in MEF is easy. [ImportMany(typeof(IModule))] public List<IModule> Modules {get; set;} But the
Im importing some files to make a calendar in my app, but I get
I'm importing a datetime column (SQLServer) in Solr, and the values is always 2
Does importing a module get the deployed version in KRL? Suppose I want to
I am importing excel file to my database. While importing i get the error
Importing NumPy in Python 3, I get the following error message: >>> import numpy
I am importing XML into InDesign, and I get this message: The external entity
Importing a Maven project into Eclipse has brought up the error: Plugin execution not
While importing website through content porter, I am getting an error that names and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.