1379530315 发表于 2021-2-13 17:06:51

救助这个错误要怎么解决呀

程序:
import pygame
import sys

pygame.init()

size = width, height = 600, 400
screen = pygame.display.set_mode(size)
pygame.display.set_caption("事件显示")
bg = (0, 0, 0)

font = pygame.font.Font(None, 20)
line_height = font.get_linesize()
position = 0

screen.fill(bg)

while True:
    for event in pygame.event.get():
      if event.type == QUIT:
            sys.exit()

      screen.blit(font.render(str(event), True, (0, 255, 0), (0, position)))
      position += line_height

      if position >height:
            position = 0
            screen.fill(bg)

      pygame.display.filp()
————————————————————————————————————————————————————————————————————————
错误:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\pygame\pkgdata.py", line 50, in getResource
    if resource_exists(pkgname, identifier):
File "D:\python\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 1135, in resource_exists
    return get_provider(package_or_requirement).has_resource(resource_name)
File "D:\python\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 1406, in has_resource
    return self._has(self._fn(self.module_path, resource_name))
File "D:\python\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 1475, in _has
    "Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type

Daniel_Zhang 发表于 2021-2-13 17:54:24

The issue is that your tests directory (and possibly any subdirectories) is not a Python module.

In order to fix this, add an __init__.py file to the tests directory (and possibly any subdirectories). In order to resolve the issue outlined above, it does not need any content

试试这个?要是搞不了那也没办法{:10_245:}

ncx0331 发表于 2021-2-13 21:22:38

你这程序没发完啊,错误在一千多行

Daniel_Zhang 发表于 2021-2-13 21:47:25

ncx0331 发表于 2021-2-13 21:22
你这程序没发完啊,错误在一千多行

那个1000+的应该是python自己的init文件吧{:10_277:}

1379530315 发表于 2021-2-13 22:32:47

ncx0331 发表于 2021-2-13 21:22
你这程序没发完啊,错误在一千多行

对,这是Python自己的程序

1379530315 发表于 2021-2-13 22:35:03

Daniel_Zhang 发表于 2021-2-13 17:54
The issue is that your tests directory (and possibly any subdirectories) is not a Python module.

...

已经有__init__.py文件了,也没有其他的子目录,不知道是什么原因,现在打算去问问老师了。谢谢您
页: [1]
查看完整版本: 救助这个错误要怎么解决呀