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 1105109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:34:48+00:00 2026-05-17T01:34:48+00:00

Today is the first time I’ve used Python, so I’m sure this’ll be an

  • 0

Today is the first time I’ve used Python, so I’m sure this’ll be an easy question.

I need to convert this Python script from a command line application: webkit2png. The end result will be a URL that returns an image of the webpage passed into it as a querystring param. I’ve achieved this on Windows with .NET and IE, Gecko and WebKit, but now need to do the same for Safari on OS X.

I think I’ve got it converted, but unfortunately I’m running into a problem running the script from Apache on OS X:

app = AppKit.NSApplication.sharedApplication()

# create an app delegate
delegate = AppDelegate.alloc().init()
AppKit.NSApp().setDelegate_(delegate)

# create a window
rect = Foundation.NSMakeRect(0,0,100,100)
win = AppKit.NSWindow.alloc()
win.initWithContentRect_styleMask_backing_defer_ (rect, 
        AppKit.NSBorderlessWindowMask, 2, 0)

The error is thrown on the final line “initWithContentRect…”. The error I see is:

<class 'objc.error'>: NSInternalInconsistencyException - Error (1002) creating CGSWindow 
  args = ('NSInternalInconsistencyException - Error (1002) creating CGSWindow',) 
  message = 'NSInternalInconsistencyException - Error (1002) creating CGSWindow' 
  name = u'NSInternalInconsistencyException'

If I run the script on the command line (after removing the CGI stuff), it runs perfectly.

Here’s the libraries I’m importing:

import cgi
import cgitb; cgitb.enable()  # for troubleshooting              
import sys
try:
  import Foundation
  import WebKit
  import AppKit
  import objc
except ImportError:
  print "Cannot find pyobjc library files.  Are you sure it is installed?"
  sys.exit()
  • 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-17T01:34:49+00:00Added an answer on May 17, 2026 at 1:34 am

    You cannot (usually) connect to the window server from a process not associated to a GUI user. See this Apple tech note.
    Basically, it’s a big no-no to use NSWindow etc. from the process spawned by Apache. The window server is not even guaranteed to exist if there’s no GUI user logged in. So, you can’t reliably do what you’re trying to do.

    The problem is that the WebKit which comes with OS X depends on the window server. One way out might be to install Qt, which hopefully has a backend of WebKit independent of the Core Graphics window server.

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

Sidebar

Related Questions

I came across the Python with statement for the first time today. I've been
I'm trying Google AppEngine and Python today for the first time and managed to
I am working with Soap for the first time today. But know i need
I am using directlabels for the first time today and as this is a
Today is my first time to try Java language. When I try this code,
As usual the question comes from a first time user of Android. Its three
I used Self SSL for the first time today to create a certificate for
This is the first time I've used Node.js and Mongo, so please excuse any
Today is the first time I ever expose to LINQ so to say I
I tried using PHPDoc for the first time today and quickly ran into a

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.