|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 言16 于 2020-10-6 16:05 编辑
运行一个PyGame程序,代码如下:
- import pygame
- import sys
- print('\n- - - - - - - -\n')
- # 初始化Pygame
- pygame.init()
- size = width, height = 600, 400
- screen = pygame.display.set_mode(size)
- pygame.display.set_caption("FishC Demo")
- bg = (0, 0, 0)
- font = pygame.font.Font(None, 20)
- line_height = font.get_linesize()
- position = 0
- screen.fill(bg)
- screen.blit(font.render('测试区\nTest Area', True, (0, 255, 0)), (0, 1))
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit()
- print(str(event))
- if position > height:
- position = 0
复制代码
运行后,出现如下异常:
- Traceback (most recent call last):
- File "C:\Users\Administrator\Desktop\pg_3.py", line 1, in <module>
- import pygame
- File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pygame\__init__.py", line 133, in <module>
- from pygame.rect import Rect
- ModuleNotFoundError: No module named 'pygame.rect'
复制代码
即pygame.rect文件丢失或模块未找到。
文件拷贝到另一个电脑上,出错信息如下:
- Traceback (most recent call last):
- File "C:\Users\Administrator\Desktop\pg_3.py", line 1, in <module>
- import pygame
- File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pygame\__init__.py", line 133, in <module>
- from pygame.base import *
- ModuleNotFoundError: No module named 'pygame.base'
复制代码
即pygame.base文件丢失或模块未找到。请问是什么原因导致这些异常,还有如何解决?
@小甲鱼 @zltzlt
|
|