0
点赞
收藏
分享

微信扫一扫

Ubuntu安装Pygame模块

闲云困兽 2021-09-22 阅读 112
日记本

--安装命令1.0

sudo pip3 install pygame
出现错误
 ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-464at5p5/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-464at5p5/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-rslm0xh6
         cwd: /tmp/pip-install-464at5p5/pygame/
    Complete output (29 lines):
    
    
    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using UNIX configuration...
    
    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    Package freetype2 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    /bin/sh: 1: freetype-config: not found
    /bin/sh: 1: freetype-config: not found
    /bin/sh: 1: freetype-config: not found
    
    Hunting dependencies...
    WARNING: "sdl-config" failed!
    WARNING: "pkg-config freetype2" failed!
    WARNING: "freetype-config" failed!
    Unable to run "sdl-config". Please make sure a development version of SDL is installed.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

进入官网安装命令详解

找到Ubuntu中pygame安装命令

--安装命令2.0

sudo apt-get install python3-pygame

--测试pygame安装成功

python3 -m pygame.examples.aliens

出现错误

ubuntu@ubuntu-virtual-machine:~$ python3 -m pygame.examples.aliens
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
/usr/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No module named 'pygame.examples')

原因是python 3.8 需使用 pygame 2.0以上,而你的pygame版本为1.9。

可以在终端输入下述指令:

python3 -m pip install pygame==2.0.0.dev6

再次测试

python3 -m pygame.examples.aliens

出现此动画代表测试成功?

举报

相关推荐

0 条评论