Pyglet-无法创建UTF8文本属性

问题描述 投票:1回答:1

我正在尝试遵循有关使用python和'acrade'软件包进行游戏开发的指南。我已经使用以下命令安装了街机:(我使用的是Linux)

pip3 install arcade

然后,我尝试编译以下代码以测试新安装的软件包:

import arcade

SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600

arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Drawing Example")

arcade.set_background_color(arcade.color.WHITE)

arcade.start_render()

x = 300
y = 300
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)

x = 370
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

x = 230
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

x = 300
y = 280
width = 120
height = 100
start_angle = 190
end_angle = 350
arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK, start_angle, end_angle, 10)

arcade.finish_render()

arcade.run()

我收到以下错误:

  File "/home/beewulf/.local/lib/python3.6/site-packages/pyglet/window/xlib/__init__.py", line 805, in _set_text_property
    raise XlibException('Could not create UTF8 text property')
pyglet.window.xlib.XlibException: Could not create UTF8 text property

我尝试按照[https://github.com/openai/gym/issues/673]但这没有用。

任何人有任何想法吗?

python pyglet
1个回答
0
投票

您得到pyglet.window.xlib.XlibException: Could not create UTF8 text property,因为您的语言环境配置不正确。此错误来自语言环境中的LANG属性。

这可以通过解决

在您的终端中

  1. LANG=en_US
  2. 从终端运行python代码

另一种解决方案是通过在代码的开头(在所有内容之前)添加这段代码来为代码配置语言环境

import os
os.environ['LANG']='en_US'
© www.soinside.com 2019 - 2024. All rights reserved.