【问题标题】:pygame installation: sdl-config command not foundpygame 安装:找不到 sdl-config 命令
【发布时间】:2013-10-25 01:19:58
【问题描述】:

我用过

./configure --prefix=$HOME
make
make install

安装 sdl2, 之后我尝试通过

安装 pygame
cd ../pygame-1.9.1release/
python setup.py install

但我收到一个错误:

linuxnx:~/python/library/pygame-1.9.1release> python setup.py install
WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...
Hunting dependencies...
sh: sdl-config: command not found
WARNING: "sdl-config" failed!
sh: smpeg-config: command not found
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.

【问题讨论】:

  • 如果您使用 pip 安装,则不必手动安装 SDL。
  • 实际上不是这样。我从pip3 install tensor2tensor 遇到了这个错误。

标签: python installation pygame


【解决方案1】:

我搜索了很长时间,因为我需要 Eric Matthes 的 Python Crash Course 包,但找不到有助于运行的答案 pip install pygame 没有错误,终于找到了适合我的 1 行解决方案

sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev

【讨论】:

  • +1,即使我必须为“外星人入侵”项目安装超过 100 MB 的附加软件包,这个简单的解决方案也会对许多人有用...
  • 终于!我尝试了所有其他答案,但没有任何效果。这终于奏效了。谢谢
  • @GTK1.2.6fanboy 最好为入侵做好准备,而不是匆忙安装那些额外的 MB,我猜 :)
【解决方案2】:

我看到这个帖子已经存在了很长时间,但我认为将其留在此处以防它对某人有所帮助是个好主意。 我在a website 上发现了这些可能有帮助的行:

目前,2020 年 5 月 1 日,您无法将 pygame 库安装在 python 3.8 和 pip install pygame,你可以用一个 它们的特定版本,仍然适用于开发人员。您可以安装 Python 3.8 在命令行使用这个版本:pip install pygame==2.0.0.dev6 最新版本:pip install pygame==2.0.0.dev10

我不知道你是否使用 python3,但除了 sdl 之外,它会给我带来更多错误 以及freetype-config ...在我使用“python3 -m pip install pygame”之前。

:~$ python3 -m pip install pygame==2.0.0.dev10
Collecting pygame==2.0.0.dev10
  Downloading pygame-2.0.0.dev10-cp38-cp38-manylinux1_x86_64.whl (14.3 MB)
     |████████████████████████████████| 14.3 MB 130 kB/s
Installing collected packages: pygame
Successfully installed pygame-2.0.0.dev10

所有人的编程时间都很好!! =)

【讨论】:

    【解决方案3】:

    原件:2013.10.25

    PyGame-1.9.1 是在 2009 年创建的,所以它仍然使用旧的 SDL 1.2 而不是新的 SDL2。

    PySDL2 使用 SDL2


    编辑:2021.10.17

    问题和我的原始答案已经快 8 岁了,似乎作者在我的旧答案中从 URL 中删除了PySDL2。他将代码从bitbucket 移动到github

    使用谷歌我发现

    同时PyGame开始使用SDL2

    另请参阅releases

    【讨论】:

    • PySDL2 返回 404
    • @moudrick 这个答案已经 8 岁了。似乎作者从这个 URL 中删除了PySDL2。但是如果你使用谷歌,那么你应该找到新的地方。 pysdl2.readthedocs.io/en/rel_0_9_7。顺便说一句:据我所知,当前 PyGame 使用 SDL2
    【解决方案4】:

    在终端试试这个,它应该安装 sdl 1.2 # 创建一个临时目录,我们可以在其中下载和构建东西

    mkdir tmp
    cd tmp
    
    # download and install SDL
    wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
    tar -xzvf SDL-1.2.14.tar.gz
    cd SDL-1.2.14
    ./configure 
    sudo make all
    

    【讨论】:

      【解决方案5】:

      在我阅读了上面的最佳答案后,

      我安装了python-dev、libsdl-image1.2-dev。

      然后我得到了

      Hunting dependencies...
      WARNING: "pkg-config freetype2" failed!
      WARNING: "freetype-config" failed!
      SDL     : found 1.2.15
      FONT    : not found
      IMAGE   : found
      MIXER   : not found
      PNG     : found
      JPEG    : found
      SCRAP   : found
      PORTMIDI: not found
      PORTTIME: not found
      FREETYPE: not found
      Missing dependencies
      

      所以我刚刚安装了这些并且它工作了。

      sudo apt install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libportmidi-dev libfreetype6-dev
      

      【讨论】:

        【解决方案6】:

        这个错误在 Pygame-2.0.0.dev12 中再次出现

        我的解决方案是:

        sudo apt-get install libsdl2-dev
        

        然后我得到了

        Hunting dependencies...
        SDL     : found 2.0.9
        FONT    : not found
        IMAGE   : not found
        MIXER   : not found
        PNG     : found
        JPEG    : found
        SCRAP   : found
        PORTMIDI: found
        PORTTIME: found
        FREETYPE: found 22.1.16
        

        所以我在下面运行了这个命令:

        sudo apt-get install libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev
        

        总结缺少的依赖项

        【讨论】:

          猜你喜欢
          • 2014-07-04
          • 1970-01-01
          • 2013-03-28
          • 2016-11-04
          • 2022-01-12
          • 2018-06-17
          • 2014-01-13
          • 2015-07-20
          • 2014-09-25
          相关资源
          最近更新 更多