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

  • Home
  • SEARCH
  • 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 6876633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:30:07+00:00 2026-05-27T04:30:07+00:00

I have a pyobjc app running in a 32-bit only python build that makes

  • 0

I have a pyobjc app running in a 32-bit only python build that makes use of the gevent library. Everything works great in py2app’ed alias mode, but once I build an app bundle, the gevent module can’t find the httplib library, even if it was bundled with the site-packages directory.

File "gevent/monkey.pyo", line 182, in patch_httplib
File "gevent/httplib.pyo", line 8, in <module>
ImportError: No module named httplib

I’ve tried false importing as suggested (even if the module seems to have been packaged), but to no avail. It can find the gevent.httplib module but not the module it’s supposed to monkey patch. could this be a problem with the monkey patching feature?

EDIT: it looks like find_module isn’t working properly with my py2app bundle. Is there a workaround to this? I don’t think it’s a problem with dotted modules as httplib isn’t dotted (it’s part of the core python libs)

EDIT 2: so it definitely is imp.find_module. Using import(‘httplib’) instead of load_module fixes it, but I had to delete the reference to ‘httplib’ in sys.modules because it can’t monkey patch if it’s already loaded. I don’t think this is the correct way to do it though, though the built app bundle works properly (httplib is now monkey patched and allows init with HTTPSConnection). Is there any workaround/fix to this py2app problem?

  • 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-05-27T04:30:07+00:00Added an answer on May 27, 2026 at 4:30 am

    It is a bit tricky and involves even more patching, but definitely solvable:

    def main():
    
        # Patch the imp standard library module to fix an incompatibility between
        # py2app and gevent.httplib while running a py2app build on Mac OS-X.
        # This patch must be executed before applying gevent's monkey patching.
        if getattr(sys, 'frozen', None) == 'macosx_app':
    
            import imp, httplib
    
            original_load_module = imp.load_module
            original_find_module = imp.find_module
    
            def custom_load_module(name, file, pathname, description):
                if name == '__httplib__':
                    return httplib
                return original_load_module(name, file, pathname, description)
    
            def custom_find_module(name, path=None):
                if name == 'httplib':
                    return (None, None, None)
                return original_find_module(name, path)
    
            imp.load_module = custom_load_module
            imp.find_module = custom_find_module
    
            # Verify that the patch is working properly (you can remove these lines safely)
            __httplib__ = imp.load_module('__httplib__', *imp.find_module('httplib'))
            assert __httplib__ is httplib
    
            # Your application here
    
    if __name__ == '__main__':
        main()
    

    This solution is more complex than simply modifying gevent.httplib, but at least works with the stock gevent 0.13 distribution. I haven’t tried it with the recently released gevent 1.0 alpha versions yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
I have a program that uses OpenGL combined with Cocoa and Python using PyObjC.
Have a webapplication with backend developed on python ( running on Django) and front
I have a plugin written entirely in Python using PyObjC whose core classes I
Using the Python templates for Xcode, I have a simple project running on one
Have a fun issue with sharepoint calendar view filtering. That code works fine: SPSecurity.RunWithElevatedPrivileges(delegate()
Have a rails app that is supposed to display a list of products/managers. After
Have a bunch of WCF REST services hosted on Azure that access a SQL
Have a photography site that I want to prevent image copying from. How can
I have the following PyObjC script: from Foundation import NSObject import QTKit error =

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.