Pygame installation failed: metadata-generation-failed [duplicate] - python

This question already has answers here:
How to install pygame?
(4 answers)
Unable to install Pygame using pip
(27 answers)
Closed 14 days ago.
I tried to install pygame, but the following error was shown in the console. How can I properly install pygame without any errors?
× 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.
PS C:\Users\HP> py -m pip install setuptools -U
Requirement already satisfied: setuptools in c:\users\hp\appdata\local\programs\python\python311\lib\site-packages (65.5.0)
Collecting setuptools
Downloading setuptools-67.1.0-py3-none-any.whl (1.1 MB)
---------------------------------------- 1.1/1.1 MB 1.4 MB/s eta 0:00:00
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 65.5.0
Uninstalling setuptools-65.5.0:
Successfully uninstalled setuptools-65.5.0
Successfully installed setuptools-67.1.0
PS C:\Users\HP> 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\HP\AppData\Local\Temp\pip-install-384h3q66\pygame_166167a860e649829039ff1d78b95041\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.

Related

Installing pygame with using pip but it shows error [duplicate]

C:\Users\matth>pip3 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.
New answer (Feb 2023)
pip install pygame-ce
^ pygame-ce (pygame community edition) is a modern fork of pygame by many pygame contributors that supports 3.11 out of the box, just recently launched. See https://github.com/pygame-community/pygame-ce/tree/main
Short answer
pip install pygame --pre is necessary right now due to your Python version
Long answer
Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)
The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don't have a pygame development environment set up.
However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.
Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.
If you are using poetry. Do the following:
poetry add pygame=2.1.3.dev8
If you are using pip. Do the following:
pip install pygame --pre
Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version. You can also have 2 version of python installed.
To work with each one use:
py -3.10 script.py
py -3.11 script.py

pgame will not install [duplicate]

C:\Users\matth>pip3 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.
New answer (Feb 2023)
pip install pygame-ce
^ pygame-ce (pygame community edition) is a modern fork of pygame by many pygame contributors that supports 3.11 out of the box, just recently launched. See https://github.com/pygame-community/pygame-ce/tree/main
Short answer
pip install pygame --pre is necessary right now due to your Python version
Long answer
Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)
The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don't have a pygame development environment set up.
However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.
Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.
If you are using poetry. Do the following:
poetry add pygame=2.1.3.dev8
If you are using pip. Do the following:
pip install pygame --pre
Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version. You can also have 2 version of python installed.
To work with each one use:
py -3.10 script.py
py -3.11 script.py

Pygame not installing. It's saying "The error generates from a sub process, and is likely not a problem with pip." [duplicate]

C:\Users\matth>pip3 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.
New answer (Feb 2023)
pip install pygame-ce
^ pygame-ce (pygame community edition) is a modern fork of pygame by many pygame contributors that supports 3.11 out of the box, just recently launched. See https://github.com/pygame-community/pygame-ce/tree/main
Short answer
pip install pygame --pre is necessary right now due to your Python version
Long answer
Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)
The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don't have a pygame development environment set up.
However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.
Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.
If you are using poetry. Do the following:
poetry add pygame=2.1.3.dev8
If you are using pip. Do the following:
pip install pygame --pre
Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version. You can also have 2 version of python installed.
To work with each one use:
py -3.10 script.py
py -3.11 script.py

Pygame gives an error on installation saying it cannot generate package metadata [duplicate]

C:\Users\matth>pip3 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.
New answer (Feb 2023)
pip install pygame-ce
^ pygame-ce (pygame community edition) is a modern fork of pygame by many pygame contributors that supports 3.11 out of the box, just recently launched. See https://github.com/pygame-community/pygame-ce/tree/main
Short answer
pip install pygame --pre is necessary right now due to your Python version
Long answer
Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)
The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don't have a pygame development environment set up.
However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.
Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.
If you are using poetry. Do the following:
poetry add pygame=2.1.3.dev8
If you are using pip. Do the following:
pip install pygame --pre
Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version. You can also have 2 version of python installed.
To work with each one use:
py -3.10 script.py
py -3.11 script.py

Pygame error "python setup.py egg_info did not run successfully." [duplicate]

C:\Users\matth>pip3 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
╰─> [80 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
update(x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
response = urllib.urlopen(request).read()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da
---
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.
New answer (Feb 2023)
pip install pygame-ce
^ pygame-ce (pygame community edition) is a modern fork of pygame by many pygame contributors that supports 3.11 out of the box, just recently launched. See https://github.com/pygame-community/pygame-ce/tree/main
Short answer
pip install pygame --pre is necessary right now due to your Python version
Long answer
Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)
The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don't have a pygame development environment set up.
However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.
Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.
If you are using poetry. Do the following:
poetry add pygame=2.1.3.dev8
If you are using pip. Do the following:
pip install pygame --pre
Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version. You can also have 2 version of python installed.
To work with each one use:
py -3.10 script.py
py -3.11 script.py

Categories

Resources