1

I am a newbie of Python and Pyglet. I just installed Pyglet on my Linux and Window7. I run a very simple test file on my Linux, I got errors

(On linux: Python 3.5.2 Pyglet 1.2.4)

The following is the test file-tests.py:

import pyglet

window = pyglet.window.Window()
pyglet.app.run()

I got the following errors when I run it on my Linux:

Traceback (most recent call last):

File "/home/work/.local/lib/python3.5/site-packages/pyglet/init.py", line 351, in getattr return getattr(self._module, name)

AttributeError: 'NoneType' object has no attribute 'Window'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 6, in <module> window = pyglet.window.Window() File "/home/work/.local/lib/python3.5/site-packages/pyglet/init.py", line 357, in getattr import(import_name)

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/init.py", line 1816, in <module> gl._create_shadow_window()

File "/home/work/.local/lib/python3.5/site-packages/pyglet/gl/init.py", line 205, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False)

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 163, in init super(XlibWindow, self).init(args, *kwargs)

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/init.py", line 558, in init self._create()

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 353, in _create self.set_caption(self._caption)

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 513, in set_caption self._set_text_property('_NET_WM_NAME', caption)

File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 783, in _set_text_property raise XlibException('Could not create UTF8 text property')

pyglet.window.xlib.XlibException: Could not create UTF8 text property*

This test file works ok on my Win7

(On Window7: Python 3.6.0 Pyglet 1.2.4)

Please help if you know why. Thanks.

8
  • 1
    Were there any error messages when you installed pyglet? This has the markings of a failed install. Commented Jan 6, 2017 at 16:06
  • I used: pip3 install pyglet : I got: "Installing collected packages: pyglet Successfully installed pyglet-1.2.4" Commented Jan 6, 2017 at 16:25
  • @anch0ret sudo pip install pyglet Commented Jan 6, 2017 at 16:49
  • 1
    Have you installed mesa and other graphical dependencies? It looks like you're running a non-standard locale, what's in your /etc/locale.conf (The uncommented lines) Commented Jan 6, 2017 at 18:23
  • 1
    @Torxed "non-standard locale" which you mentioned solved my problem. Thank you very much. By the way, How can I vote for you? Commented Jan 7, 2017 at 2:51

3 Answers 3

1

As we figured out from the comments above, it looked like the installation output printed some odd symbols. That and the fact that pyglet had problem loading UTF-8 context lead me to believe that there were no UTF-8 support generated in the OS.

Usually, you can uncomment en_US.UTF-8 in /etc/locale.conf and run locale-gen and that should solve the problem.

Sign up to request clarification or add additional context in comments.

Comments

1

in your terminal

  1. write LANG=en_US
  2. Run your python code from the terminal

another solution by placing it before everything of your code

import os
os.environ['LANG']='en_US'

2 Comments

make it: import os os.environ['LANG']='en_US.UTF-8'
Unlike setting the environment variable from outside the program, changing the environment as the first thing in the program itself, does not seem to change the issue, at least in my setup with python 3.8.3.
0
  1. edit your /etc/default/locale, and try to feed all locale critiria as the same:
#  File generated by update-locale
LANG=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=en_US.UTF-8
  1. Use sudo dpkg-reconfigure locales to set your own language. Make sure to mark en_US.UTF-8 selection.
  2. sudo locale-gen en_US en_US.UTF-8
  3. Reboot

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.