【问题标题】:Pygame.transform.rotate causes fatal pygame errorPygame.transform.rotate 导致致命的 pygame 错误
【发布时间】:2020-07-15 09:52:10
【问题描述】:

我正在尝试使用 python 和 pygame 制作游戏,但需要使用 pygame.transform.rotate。正如我所说,出现以下错误消息:(c:/Users/foxcirc/Desktop/rxry 是项目路径)

Fatal Python error: (pygame parachute) Segmentation Fault
Thread 0x00002890 (most recent call first):
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 296 in wait
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_io.py", line 40 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 27 in read_request
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 215 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\buffered\__init__.py", line 39 in _read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 14 in readall
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 32 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 164 in read_message_begin
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 372 in read_message_begin
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 212 in process_in
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 257 in process
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_server.py", line 34 in handle
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 885 in _bootstrap
Thread 0x00002e58 (most recent call first):
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_io.py", line 110 in readall
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 45 in _read_frame
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 37 in _read_and_dispatch_next_frame
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 64 in _read_forever
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 885 in _bootstrap
Current thread 0x00002964 (most recent call first):
  File "<string>", line 9 in __init__
  File "C:/Users/foxcirc/Desktop/rxry/game/scripts/main.py", line 132 in <module>
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18 in execfile
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197 in runfile
  File "<input>", line 1 in <module>
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\code.py", line 90 in runcode
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\code.py", line 74 in runsource
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_console_types.py", line 35 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 84 in do_add_exec
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_code_executor.py", line 106 in add_exec
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 258 in process_exec_queue
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 411 in start_client
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 483 in <module>

这里是我所有的导入,如果这很重要的话:

import pygame
from pickle import load as pickload
from os import chdir, walk; chdir(gamedir); del chdir
from sys import path; path.extend(gamedir); del path 

我尝试不导入泡菜,但没有任何改变。 我还尝试从程序的另一个“部分”调用该函数。

这是我使用 pygame.tranform.rotate 的方法: pygame.transform.rotate(self.bsurface, 10)

使用 python 3.7(32 位)和 pygame 版本 1.9.6。

【问题讨论】:

  • 尝试更新到 pygame 2.0.0.dev6 或更高版本没有多大帮助。有时它可以解决像这样的问题
  • 我怎样才能得到这个版本的pygame?来自github?
  • 以管理员身份打开 cmd/powershell 并输入 pip install pygame==2.0.0.dev6
  • 我安装了版本,但它并没有解决问题,而且性能下降但还是谢谢。
  • 你如何使用pygame.transform.rotate?这很可能是您的应用程序中的一个错误,该错误是由pygame.transform.rotate 的不当使用引起的。我投票结束这个问题,因为没有Minimal, Reproducible Example。

标签: python python-3.x exception pygame


【解决方案1】:

我尝试了几件事,现在我发现了错误!

事实证明,我在函数中使用的表面最初的宽度和长度为 0。
在宽度和/或高度为 0 的表面上调用 pygame.transform.rotate 函数显然不会产生花哨的 “你不能调用这个表面的宽度为 0" 消息。你只是得到一个段错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多