|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在pycharm中安装pygame模块后,导入该模块时出现“找不到指定程序”
- import sys
- import pygame
- def run_game():
- # 初始化游戏并创建一个屏幕对象
- pygame.init()
- screen = pygame.display.set_mode((1200, 800))
- pygame.display.set_caption("Alien Invasion")
- # 设置背景色
- bg_color = (230, 230, 230)
- # 开始游戏的主循环
- while True:
- # 监视键盘和鼠标事件
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit()
- # 每次循环时都重绘屏幕
- screen.fill(bg_color)
- # 让最近绘制的屏幕可见
- pygame.display.flip()
- run_game()
复制代码
- Traceback (most recent call last):
- File "F:\游戏\alien_invasion\alien_invasion.py", line 2, in <module>
- import pygame
- File "C:\Users\admin\AppData\Roaming\Python\Python39\site-packages\pygame\__init__.py", line 83, in <module>
- from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
- ImportError: DLL load failed while importing base: 找不到指定的程序。
复制代码
重装 pygame 即可~
注意要检查 pygame 版本呢~
|
|