I realize this is really old, but I recently ran into a very similar 
problem and was wondering if you or anyone has found a solution for Mac OS 
X?

Specifically, I 'm trying to 
run 
https://github.com/AppliedDataSciencePartners/WorldModels/blob/master/05_train_controller.py
 
on my iMac. It's not headless, but as soon as my screensaver kicks in I get 
the same error...

   screen = display.get_default_screen()
 File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyglet/canvas/base.py",
 
line 73, in get_default_screen
   return self.get_screens()[0]
IndexError: list index out of range

Accessing the Quartz window system in any non-standard way has always been 
a problem for OS X, but I had hoped maybe there was a solution by now.

My current work-around is to disable my screensaver, but that also means my 
computer isn't locked. Not something I care to do, especially given that 
script could be running for days at a time.


On Saturday, October 3, 2015 at 8:52:34 AM UTC-7, Andrea Cuttone wrote:
>
> All right I finally managed to make it run on Linux:
>
> xvfb-run -s "-screen 0 1400x900x24" python hello_world.py 
>
> This runs without problems on Ubuntu 12.04 and 14.04, and Mint 17.2.
>
> Still no luck on OSX. I guess the problem is that pyglet as most apps in 
> OSX uses Quartz instead of X11, so Xvfb does nothing.
>
>
> On Tuesday, September 29, 2015 at 3:51:15 PM UTC-4, Andrea Cuttone wrote:
>>
>> I now tried on a Ubuntu 13.10 machine
>>
>> I run xvfb-run ipython hello_world.py 
>> <https://github.com/benatkin/pyglet-stuff/blob/master/hello_world.py>:
>>
>> Traceback (most recent call last):
>>   File "hello_world.py", line 3, in <module>
>>     window = pyglet.window.Window()
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/__init__.py", line 
>> 357, in __getattr__
>>     __import__(import_name)
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/window/__init__.py", 
>> line 1817, in <module>
>>     gl._create_shadow_window()
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/gl/__init__.py", 
>> line 205, in _create_shadow_window
>>     _shadow_window = Window(width=1, height=1, visible=False)
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py",
>>  
>> line 163, in __init__
>>     super(XlibWindow, self).__init__(*args, **kwargs)
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/window/__init__.py", 
>> line 559, in __init__
>>     self._create()
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py",
>>  
>> line 210, in _create
>>     visual_info = self.config.get_visual_info()
>>   File 
>> "/home/andrea/.local/lib/python2.7/site-packages/pyglet/gl/xlib.py", line 
>> 182, in get_visual_info
>>     self.canvas.display._display, self._fbconfig).contents
>> ValueError: NULL pointer access
>>
>>
>>
>>
>> On Tuesday, September 29, 2015 at 11:11:14 AM UTC-4, swiftcoder wrote:
>>>
>>> What are the chances you can switch to a Linux server?
>>>
>>> It's likely to be a lot simpler to get X to give you a headless 
>>> framebuffer (or MESA equivalent), then to rewrite pyglet's OS X 
>>> implementation to allow headless operation.
>>> On Tue, Sep 29, 2015 at 07:20, Andrea Cuttone <andrea...@gmail.com> 
>>> wrote:
>>>
>>>> the app is already written using pyglet. Wouldn't that require to 
>>>> complete rewrite it using pycairo?
>>>>
>>>>
>>>>
>>>> Andrea Cuttone
>>>>
>>>> On Tue, Sep 29, 2015 at 10:13 AM, Andre D <an...@andred.ca> wrote:
>>>>
>>>>> Does something like pycairo fit your needs?
>>>>> On Sep 29, 2015 10:12 AM, "Andrea Cuttone" <andrea...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> The application is https://github.com/andrea-cuttone/geoplotlib, a 
>>>>>> python library for plotting geographical data.
>>>>>> The use case is running the app to render the maps, capture the 
>>>>>> framebuffer and store it to disk in form of raster images.
>>>>>> This works great when there is a physical screen attached, but it 
>>>>>> fails with a headless session.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Andrea Cuttone
>>>>>>
>>>>>> On Tue, Sep 29, 2015 at 10:05 AM, Andre D <an...@andred.ca> wrote:
>>>>>>
>>>>>>> What does the application do with pyglet that a terminal is 
>>>>>>> sufficient?
>>>>>>> On Sep 29, 2015 9:57 AM, "Andrea Cuttone" <andrea...@gmail.com> 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> remote desktop is not a good option in our setup, as it is very 
>>>>>>>> slow over VPN, and also we would like to limit the access we give to 
>>>>>>>> users 
>>>>>>>> to just a terminal.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Andrea Cuttone
>>>>>>>>
>>>>>>>> On Mon, Sep 28, 2015 at 4:37 PM, Tristam MacDonald <
>>>>>>>> swift...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> How about remote desktop'ing in, instead of headless SSH?
>>>>>>>>> On Mon, Sep 28, 2015 at 13:15, Andrea Cuttone <andrea...@gmail.com> 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> yes I guess this is the issue, since I am connected with ssh and 
>>>>>>>>>> there is no window manager running. 
>>>>>>>>>>
>>>>>>>>>> So the question is how to make pyglet use a virtual window 
>>>>>>>>>> manager such as Xvfb <https://en.wikipedia.org/wiki/Xvfb> (which 
>>>>>>>>>> is based on XQuartz)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Monday, September 28, 2015 at 4:12:08 PM UTC-4, Rob wrote:
>>>>>>>>>>>
>>>>>>>>>>> I guess this answers it:
>>>>>>>>>>>
>>>>>>>>>>> Sep 28 21:58:49 1.1.1.1 python[14740] <Error>: This user is not 
>>>>>>>>>>> allowed access to the window system right now.
>>>>>>>>>>> _RegisterApplication(), FAILED TO establish the default 
>>>>>>>>>>> connection to the WindowServer, _CGSDefaultConnection() is NULL.
>>>>>>>>>>>
>>>>>>>>>>> Not sure if this is something we could fix in pyglet, or whether 
>>>>>>>>>>> it is a system config thing.
>>>>>>>>>>>
>>>>>>>>>>> Rob
>>>>>>>>>>>
>>>>>>>>>>> Op maandag 28 september 2015 22:03:08 UTC+2 schreef Andrea 
>>>>>>>>>>> Cuttone:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> here is the output of `python -m pyglet.info` on the server
>>>>>>>>>>>>
>>>>>>>>>>>> https://gist.github.com/andrea-cuttone/61e3dd1f71c5f58b8996
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Andrea Cuttone
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Sep 28, 2015 at 3:50 PM, Rob <silves...@gmail.com> 
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Can you check what `python -m pyglet.info` returns?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Rob
>>>>>>>>>>>>>
>>>>>>>>>>>>> Op maandag 28 september 2015 21:16:34 UTC+2 schreef Andrea 
>>>>>>>>>>>>> Cuttone:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hello
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I am trying to run a hello world pyglet app on OSX 10.10, 
>>>>>>>>>>>>>> where I connect through ssh. 
>>>>>>>>>>>>>> When doing that, I get the following error:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /Users/ancu/pyglet-1.2.3/pyglet/canvas/base.pyc in 
>>>>>>>>>>>>>> get_default_screen(self)
>>>>>>>>>>>>>>      72         :rtype: :class:`Screen`
>>>>>>>>>>>>>>      73         '''
>>>>>>>>>>>>>> ---> 74         return self.get_screens()[0]
>>>>>>>>>>>>>>      75
>>>>>>>>>>>>>>      76     def get_windows(self):
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> IndexError: list index out of range
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> which I assume is due to the fact that no Window Manager is 
>>>>>>>>>>>>>> running.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I saw that some people suggest to use the virtual X server 
>>>>>>>>>>>>>> Xvfb. However even if I have Xvfb running, pyglet seem to not 
>>>>>>>>>>>>>> detect it.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Does anyone have experience on how to solve this? 
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Best,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Andrea
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -- 
>>>>>>>>>>>>> You received this message because you are subscribed to a 
>>>>>>>>>>>>> topic in the Google Groups "pyglet-users" group.
>>>>>>>>>>>>> To unsubscribe from this topic, visit 
>>>>>>>>>>>>> https://groups.google.com/d/topic/pyglet-users/p4Jz4g2QXKs/unsubscribe
>>>>>>>>>>>>> .
>>>>>>>>>>>>> To unsubscribe from this group and all its topics, send an 
>>>>>>>>>>>>> email to pyglet-users...@googlegroups.com.
>>>>>>>>>>>>> To post to this group, send email to 
>>>>>>>>>>>>> pyglet...@googlegroups.com.
>>>>>>>>>>>>> Visit this group at 
>>>>>>>>>>>>> http://groups.google.com/group/pyglet-users.
>>>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> -- 
>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>> Google Groups "pyglet-users" group.
>>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>>>> send an email to pyglet-users...@googlegroups.com.
>>>>>>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>>>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>>> You received this message because you are subscribed to a topic in 
>>>>>>>>> the Google Groups "pyglet-users" group.
>>>>>>>>> To unsubscribe from this topic, visit 
>>>>>>>>> https://groups.google.com/d/topic/pyglet-users/p4Jz4g2QXKs/unsubscribe
>>>>>>>>> .
>>>>>>>>> To unsubscribe from this group and all its topics, send an email 
>>>>>>>>> to pyglet-users...@googlegroups.com.
>>>>>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "pyglet-users" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to pyglet-users...@googlegroups.com.
>>>>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to a topic in 
>>>>>>> the Google Groups "pyglet-users" group.
>>>>>>> To unsubscribe from this topic, visit 
>>>>>>> https://groups.google.com/d/topic/pyglet-users/p4Jz4g2QXKs/unsubscribe
>>>>>>> .
>>>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>>>> pyglet-users...@googlegroups.com.
>>>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "pyglet-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to pyglet-users...@googlegroups.com.
>>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to a topic in the 
>>>>> Google Groups "pyglet-users" group.
>>>>> To unsubscribe from this topic, visit 
>>>>> https://groups.google.com/d/topic/pyglet-users/p4Jz4g2QXKs/unsubscribe
>>>>> .
>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>> pyglet-users...@googlegroups.com.
>>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "pyglet-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to pyglet-users...@googlegroups.com.
>>>> To post to this group, send email to pyglet...@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to