[Python]pip install pygame安装报错解决方案
Posted shuijing2486
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Python]pip install pygame安装报错解决方案相关的知识,希望对你有一定的参考价值。
pip install pygame报错提示:
Microsoft Windows [版本 10.0.17763.3165]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\\Users\\xxxxxxx>pip install pygame
Collecting pygame
Using cached pygame-2.1.2.tar.gz (10.1 MB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [77 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\buildconfig\\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\buildconfig\\config_win.py", line 511, in main
return setup_prebuilt_sdl2(prebuilt_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\buildconfig\\config_win.py", line 471, in setup_prebuilt_sdl2
DEPS.configure()
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\buildconfig\\config_win.py", line 336, in configure
from . import vstools
File "C:\\Users\\xxxxxxx\\AppData\\Local\\Temp\\pip-install-zqq3q3ot\\pygame_1748e02cad70437b8b99abf25c9b1b20\\buildconfig\\vstools.py", line 11, in <module>
compiler.initialize()
File "C:\\Python311\\Lib\\site-packages\\setuptools\\_distutils\\msvc9compiler.py", line 403, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Python311\\Lib\\site-packages\\setuptools\\_distutils\\msvc9compiler.py", line 281, in query_vcvarsall
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
Unzipping :prebuilt_downloads\\SDL2-devel-2.0.18-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.5-VC.zip 137f86474691f4e12e76e07d58d5920c8d844d5b
Unzipping :prebuilt_downloads\\SDL2_image-devel-2.0.5-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-VC.zip 1436df41ebc47ac36e02ec9bda5699e80ff9bd27
Unzipping :prebuilt_downloads\\SDL2_ttf-devel-2.0.15-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.4-VC.zip 9097148f4529cf19f805ccd007618dec280f0ecc
Unzipping :prebuilt_downloads\\SDL2_mixer-devel-2.0.4-VC.zip:
Downloading... https://www.pygame.org/ftp/jpegsr9d.zip ed10aa2b5a0fcfe74f8a6f7611aeb346b06a1f99
Unzipping :prebuilt_downloads\\jpegsr9d.zip:
Downloading... https://pygame.org/ftp/prebuilt-x64-pygame-1.9.2-20150922.zip 3a5af3427b3aa13a0aaf5c4cb08daaed341613ed
Unzipping :prebuilt_downloads\\prebuilt-x64-pygame-1.9.2-20150922.zip:
copying into .\\prebuilt-x64
Path for SDL: prebuilt-x64\\SDL2-2.0.18
...Library directory for SDL: prebuilt-x64/SDL2-2.0.18/lib/x64
...Include directory for SDL: prebuilt-x64/SDL2-2.0.18/include
Path for FONT: prebuilt-x64\\SDL2_ttf-2.0.15
...Library directory for FONT: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64
...Include directory for FONT: prebuilt-x64/SDL2_ttf-2.0.15/include
Path for IMAGE: prebuilt-x64\\SDL2_image-2.0.5
...Library directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/lib/x64
...Include directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/include
Path for MIXER: prebuilt-x64\\SDL2_mixer-2.0.4
...Library directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64
...Include directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/include
Path for PORTMIDI: prebuilt-x64
...Library directory for PORTMIDI: prebuilt-x64/lib
...Include directory for PORTMIDI: prebuilt-x64/include
DLL for SDL2: prebuilt-x64/SDL2-2.0.18/lib/x64/SDL2.dll
DLL for SDL2_ttf: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64/SDL2_ttf.dll
DLL for SDL2_image: prebuilt-x64/SDL2_image-2.0.5/lib/x64/SDL2_image.dll
DLL for SDL2_mixer: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64/SDL2_mixer.dll
DLL for portmidi: prebuilt-x64/lib/portmidi.dll
Path for FREETYPE not found.
...Found include dir but no library dir in prebuilt-x64.
Path for PNG not found.
...Found include dir but no library dir in prebuilt-x64.
Path for JPEG not found.
...Found include dir but no library dir in prebuilt-x64.
DLL for freetype: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64/libfreetype-6.dll
---
For help with compilation see:
https://www.pygame.org/wiki/CompileWindows
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: There was an error checking the latest version of pip.
解决方案:whl安装
下载pygame安装包
下载地址:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
我安装的python版本3.11.1,win系统64位。
选择对应版本:pygame‑2.1.2‑cp311‑cp311‑win_amd64.whl
将安装包放到指定路径后进行安装
C:\\Users\\xxxxxxx>Python -m pip install --user pygame-2.1.2-cp311-cp311-win_amd64.whl
问题原因和解决思路参考:
https://q.cnblogs.com/q/142229/
dll缺失是关键问题:
这类情况直接whl安装,需要根据python版本选择whl,比如:python3.11,选文件名包含cp311。
二进制安装方式参考:
http://c.biancheng.net/pygame/installer.html
安装前置事项,重装python(这步并非解决问题的关键,只是将前述操作做记录)
控制面板内与python相关程序都卸载——刚开始只卸载了python程序,后来发现还有一个python launcher的程序未卸载。
选自定义安装方式,安装路径:C:\\Python311,将python放C盘根目录。(多数软件使用问题的通用解决思路)
自定义安装,参考: https://opentechschool.github.io/python-beginners/en/getting_started.html#what-is-python-exactly
Note
On Windows, you’ll want to add Python to your PATH, so it can be found by other programs. With Python 3.5 or later, there should be and option to do this in the installer. Otherwise, you can navigate to your installation directory (C:\\Python34\\), open the Tools, then Scripts folder, and run the win_add2path.py file by double clicking on it.
pip install pygame - 找不到 SDL.h 文件
【中文标题】pip install pygame - 找不到 SDL.h 文件【英文标题】:pip install pygame - SDL.h file not found 【发布时间】:2020-10-26 21:43:13 【问题描述】:MacOS 塞拉利昂
➜ fun_python $ pip --version
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)
pip install pygame
给我以下错误:src/scrap.c:27:10: fatal error: 'SDL.h' file not found
、error: command '/usr/bin/clang' failed with exit status 1
、#include "SDL.h"
。我在/usr/include/...
文件夹树下没有看到这个 SDL/SDL.h 文件。
给了我以下错误。
➜ fun_python $ pip install pygame
Collecting pygame
Downloading pygame-1.9.3.tar.gz (3.0MB)
100% |████████████████████████████████| 3.0MB 490kB/s
Installing collected packages: pygame
Running setup.py install for pygame ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-build-to90wzsv/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-jhi5wezf-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-3.5
creating build/lib.macosx-10.6-intel-3.5/pygame
copying lib/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/_camera_opencv_highgui.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/_camera_vidcapture.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/_dummybackend.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/_numpysndarray.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/_numpysurfarray.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/camera.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/colordict.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/compat.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/cursors.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/freetype.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/ftfont.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/locals.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/macosx.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/midi.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/pkgdata.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/sndarray.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/sprite.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/surfarray.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/sysfont.py -> build/lib.macosx-10.6-intel-3.5/pygame
copying lib/version.py -> build/lib.macosx-10.6-intel-3.5/pygame
creating build/lib.macosx-10.6-intel-3.5/pygame/gp2x
copying lib/gp2x/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/gp2x
copying lib/gp2x/constants.py -> build/lib.macosx-10.6-intel-3.5/pygame/gp2x
copying lib/gp2x/locals.py -> build/lib.macosx-10.6-intel-3.5/pygame/gp2x
creating build/lib.macosx-10.6-intel-3.5/pygame/threads
copying lib/threads/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/threads
copying lib/threads/Py25Queue.py -> build/lib.macosx-10.6-intel-3.5/pygame/threads
creating build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/__main__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/base_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/blit_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/bufferproxy_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/camera_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/cdrom_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/cdrom_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/color_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/compat_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/cursors_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/display_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/draw_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/event_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/fastevent_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/font_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/font_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/freetype_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/freetype_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/ftfont_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/ftfont_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/gfxdraw_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/image__save_gl_surface_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/image_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/image_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/imageext_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/imageext_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/joystick_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/key_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mask_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/math_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/midi_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/midi_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mixer_music_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mixer_music_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mixer_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mixer_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/mouse_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/overlay_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/pixelarray_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/pixelcopy_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/rect_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/rwobject_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/scrap_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/scrap_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/sndarray_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/sndarray_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/sprite_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/surface_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/surfarray_tags.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/surfarray_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/surflock_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/sysfont_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/test_test_.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/threads_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/time_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
copying test/transform_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/arrinter.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/async_sub.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/buftools.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/endian.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/png.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/run_tests.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/test_machinery.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
copying test/test_utils/test_runner.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/test_utils
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests
copying test/run_tests__tests/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests
copying test/run_tests__tests/run_tests__test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_4_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_5_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_6_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/no_assertions__ret_code_of_1__test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/zero_tests_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/all_ok
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_4_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/failures1
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/fake_1_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/infinite_loop
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_4_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stderr
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_4_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/print_stdout
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/fake_3_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/incomplete_todo
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/invisible_tag_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/magic_tag_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/exclude
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/sleep_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/timeout
creating build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/fake_2_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/incomplete_todo_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/magic_tag_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/sleep_test.py -> build/lib.macosx-10.6-intel-3.5/pygame/tests/run_tests__tests/everything
creating build/lib.macosx-10.6-intel-3.5/pygame/docs
copying docs/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/docs
copying docs/__main__.py -> build/lib.macosx-10.6-intel-3.5/pygame/docs
creating build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/__init__.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/aacircle.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/aliens.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/arraydemo.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/blend_fill.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/blit_blends.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/camera.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/chimp.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/cursors.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/eventlist.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/fastevents.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/fonty.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/freetype_misc.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/glcube.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/headless_no_windows_needed.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/liquid.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/mask.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/midi.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/moveit.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/oldalien.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/overlay.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/pixelarray.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/playmus.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/prevent_display_stretching.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/scaletest.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/scrap_clipboard.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/scroll.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/sound.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/sound_array_demos.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/stars.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/testsprite.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
copying examples/vgrade.py -> build/lib.macosx-10.6-intel-3.5/pygame/examples
running build_ext
building 'pygame.scrap' extension
creating build/temp.macosx-10.6-intel-3.5
creating build/temp.macosx-10.6-intel-3.5/src
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/scrap.c -o build/temp.macosx-10.6-intel-3.5/src/scrap.o
src/scrap.c:27:10: fatal error: 'SDL.h' file not found
#include "SDL.h"
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-build-to90wzsv/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-jhi5wezf-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-build-to90wzsv/pygame/
➜ fun_python $
【问题讨论】:
尝试下载并安装 SDL c/c++ 库 pygame(构建的 C 源)似乎不存在于您的平台(OSX)和您的[pypy]: pypy 上的 Python 版本,所以pip
下载源代码 (C) 并尝试构建(编译)它们,但它失败了,因为它需要 SDL ,它找不到它。也许[Macrumors]: Installing SDL 可以帮助你。
Can't install pygame with pip as there is an error whilst runningvsetup.py bdist_wheel for pygame的可能重复
@CristiFati 我同意。那篇文章中的解决方案之一,有帮助。 brew install sdl sdl_image sdl_mixer sdl_ttf portmidi && pip3 install pygame && pip install pygame
@ArunSangal 你的最新评论帮我解决了这个问题,谢谢!
【参考方案1】:
这有助于解决问题。如有必要,请使用sudo
。
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi;
pip3 install pygame;
pip install pygame
【讨论】:
【参考方案2】:按照@AKS 的brew install
回答后,它也适用于pipenv install pygame
【讨论】:
以上是关于[Python]pip install pygame安装报错解决方案的主要内容,如果未能解决你的问题,请参考以下文章
pip install pygame 在 Windows 8.1 中不起作用,但是我已经通过( C:\Python34\ )给出了路径。我该怎么办? [复制]