C:\Users\mapk0>pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
ERROR: Command errored out with exit status 1:
command: 'c:\users\mapk0\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\mapk0\\AppData\\Local\\Temp\\pip-install-uxamm092\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\mapk0\\AppData\\Local\\Temp\\pip-install-uxamm092\\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 'C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\pip-egg-info'
cwd: C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\
Complete output (17 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\mapk0\AppData\Local\Temp\pip-install-uxamm092\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
This is not exactly a bug, it’s that there are no release wheels yet for 3.11, use pip install pygame --pre
(--pre
stands for pre release), it will install pygame
2.1.3.dev8
and you can use that, 2.1.3 is coming soon but I can’t tell for sure when.
AntonioGms2007, ghanteyyy, freebird-2, Heebeaux, Be3y4uu-K0T, mikiweys, hit-the-dust, RodionYalyna, theRealProHacker, NikBandi, and 3 more reacted with laugh emoji
unowiz reacted with hooray emoji
marurunk, Px228, puisigblk, LeStefan04, bikrampun, Assentencia, Kocmocy-Da, and des5771 reacted with heart emoji
Was able to duplicate this issue with:
- Python 3.11.0
- macOS Monterey 12.6
- Pygame 2.1.2
I usedpip3 install pygame
and got a huge error message, as shown in the OP.
I do have a question, if there is no wheel made for Python3 3.11.0, is installing pygame 2.1.3.dev8
the only option? Is this release stable?
@arknaut Well, that’s the latest version of pygame
that has wheels for Python 3.11 so it would be the most stable for that version of Python. Also, yeah, it should be stable enough on its own anyways, but again, it’s kind of temporary, I can’t tell for sure (or at all) but soon wheels for 2.1.3 should be released and they will be made for 3.11 too.
@Matiiss — Okay thanks! (just clarifying) pygame 2.1.3.dev8
has been released as a temporary version of pygame so that python 3.11.0
users can continue using pygame
.
Uh, no, it’s more like 2.1.3.dev8
(it’s technically a pre-release btw) happens to have wheels for Python 3.11, it’s not specifically temporarily released for 3.11 because really 2.1.3 is kind of released already, it just doesn’t have wheels yet. But don’t take my word for it, however, I’m pretty sure it’s not something specifically done.
2.1.3dev8
is the only version with 3.11 wheels prebuilt. If you really want to use 2.1.2
, you’ll have to build the wheels yourself. But 2.1.3dev8
is essentially the full 2.1.3
release, but in pre-release form. It wasn’t specifically released to target 3.11, but since 3.11 was coming out soon, compatibility with 3.11 was added to dev8
by starbuck5 and ankith
Are there any updates on this? Or an ETA for the new Pygame version?
Hello everyone. I observe the same problem on Armbian
pip install pygame
Defaulting to user installation because normal site-packages is not writeable
Collecting pygame
Downloading pygame-2.1.2.tar.gz (10.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 3.5 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [30 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config.py", line 225, in main
deps = CFG.main(**kwds)
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config_unix.py", line 188, in main
DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
IndexError: list index out of range
Hunting dependencies...
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
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.
@rammfire if you read a few messages above, Matiiss gave the solution
@rammfire if you read a few messages above, Matiiss gave the solution
Unfortunately this is not really a solution for other packages that depend on Pygame.
For instance, I am about to release a new version of Expyriment, which depends on Pygame, and I am currently mainly holding it back due to this issue. Would be great to have some idea on when proper Python 3.11 support is planned (roughly, like within the next few days, or will it still be months?).
@fladd The full release of 2.1.3 is almost out. I’m hoping it’ll be within a week or two at most, but that’s really up to the discretion of the lead maintainer right now
Cant wait for the full release ! 😄
PeterJCLaw
added a commit
to PeterJCLaw/python-osc
that referenced
this issue
Nov 17, 2022
This was referenced
Nov 17, 2022
Though pip install pygame --pre
works on python 3.11 on my windows 11. I would like to use the release version of pygame. 😄
Looking forward to pygame-2.1.3.
C:\Users\Liu.D.H>pip install pygame --pre
Collecting pygame
Downloading pygame-2.1.3.dev8-cp311-cp311-win_amd64.whl (10.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.6/10.6 MB 4.8 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.1.3.dev8
C:\Users\Liu.D.H>
C:\Users\Liu.D.H>pip install pygame —pre
Can confirm this works. (Tested on Win10)
I would advocate for a point release that basically doesn’t change anything from the previous, but simply provides wheels for the new python version. A lot of beginners will get caught up on this while a new patch release is prepared. e.g., 2.1.3 simply ships additional 3.11 wheels, 2.1.4 gets moved to new patch release.
I would advocate for a point release that basically doesn’t change anything from the previous, but simply provides wheels for the new python version. A lot of beginners will get caught up on this while a new patch release is prepared. e.g., 2.1.3 simply ships additional 3.11 wheels, 2.1.4 gets moved to new patch release.
To the best of my knowledge, 2.1.3 is ready for release. Just waiting on the head maintainer to actually release it.
@fladd The full release of 2.1.3 is almost out. I’m hoping it’ll be within a week or two at most, but that’s really up to the discretion of the lead maintainer right now
Since it has been over a month now: Is there any news regarding the release?
Since it has been over a month now: Is there any news regarding the release?
To the best of my knowledge, the lead maintainer has not said anything to anyone in that time. Nobody else has the ability to release 2.1.3, so unfortunately we’re stuck waiting
@illume Python 3.11 has been out for a month and a half (and pygame’s main
branch has been on 2.1.4dev1
for just as long). More and more people are starting to move to 3.11 and the fact that the only version of pygame with support for 3.11 requires knowledge of how to install a prerelease might detract users from continuing to use pygame. Is there something specific holding back the release? There are also other projects that are waiting for pygame 2.1.3 to fully release so they can update their dependencies.
I’ve tried and tried, but can’t even instal the pre-release.
RPi 4B, Bullseye (64-bit), Python3.11.
pi@rxtouchlite:~/pgtest $ pip install pygame —pre
Collecting pygame
Downloading pygame-2.1.3.dev8.tar.gz (12.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.1/12.1 MB 2.8 MB/s eta 0:00:00
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/setup.py", line 399, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config.py", line 231, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py", line 189, in main
DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
~~~~~~^^^
IndexError: list index out of range
Hunting dependencies...
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
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.
Are you sure you are using the pip from python 3.11 there? Pis come with
multiple python versions. I thought you had to use pip3 on there
…
On Sat, 17 Dec 2022, 11:38 Michael Naylor, ***@***.***> wrote:
I’ve tried and tried, but can’t even instal the pre-release.
RPi 4B, Bullseye (64-bit), Python3.11.
***@***.***:~/pgtest $ pip install pygame —pre
Collecting pygame
Downloading pygame-2.1.3.dev8.tar.gz (12.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.1/12.1 MB 2.8 MB/s eta 0:00:00
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
WARNING, No «Setup» File Exists, Running «buildconfig/config.py»
Using UNIX configuration…
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File «<string>», line 2, in <module>
File «<pip-setuptools-caller>», line 34, in <module>
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/setup.py», line 399, in <module>
buildconfig.config.main(AUTO_CONFIG)
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config.py», line 231, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py», line 189, in main
DependencyProg(‘SDL’, ‘SDL_CONFIG’, ‘sdl2-config’, ‘2.0’, [‘sdl’]),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py», line 39, in __init__
self.ver = config[0].strip()
~~~~~~^^^
IndexError: list index out of range
Hunting dependencies…
—
For help with compilation see:
https://www.pygame.org/wiki/Compilation
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.
—
Reply to this email directly, view it on GitHub
<#3522 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGDGGRVNWTT24EY5AYKHATWNWQ4BANCNFSM6AAAAAARQJB5DY>
.
You are receiving this because you commented.Message ID:
***@***.***>
Are you sure you are using the pip from python 3.11 there? Pis come with multiple python versions. I thought you had to use pip3 on there
…
I think so. Both ‘pip’ and ‘pip3’ report version 22.3.1 from the same ‘penv global 3.11.0’.
Ah, I suspect it is because the pi is looking on the piwheels repository instead of PyPI and it won’t find any 3.11 wheels on piwheels because piwheels only builds wheels for a maximum of python 3.9.
If your pip is configured to use piwheels, but you want to use PyPI instead, you can remove or comment out the extra-index-url configuration in /etc/pip.conf
Otherwise you will have to learn to build pygame from source if you want to use 3.11 on a raspberry PI.
Trinkle23897
added a commit
to Trinkle23897/envpool
that referenced
this issue
Dec 28, 2022
Had same error. Used temporary fix.
Please, please, please post this solution on the homepage of Pygame!
I’m an experienced coder but new to python and spent several hours thinking I had done something wrong.
Unfortunately, the only person with access to the pygame.org website is the same person that can fix this whole mess in the first place. But, they’ve been unresponsive so far.
But, they’ve been unresponsive so far.
Bummer. First installs always seem to go sideways.
Hello, everybody.
I followed what was written here, but when I entered the «import pygame» command, I got an error (Windows can not find import
).
Who can help? Where is my mistake? Which direction in should I look for a solution to the problem?
Did you try to run import pygame
directly in command prompt? You need to be in an actual Python shell to do that (which you can get to just by typing python
Did you try to run
import pygame
directly in command prompt? You need to be in an actual Python shell to do that (which you can get to just by typingpython
Thank you! This little detail helped a lot.
I’m also trying to install from source at the moment and I’m getting the following error:
urllib.error.HTTPError: HTTP Error 503: Egress is over the account limit.
The pre-release wheel does work for me though.
thx!
This is not exactly a bug, it’s that there are no release wheels yet for 3.11, use
pip install pygame --pre
(--pre
stands for pre release), it will installpygame
2.1.3.dev8
and you can use that, 2.1.3 is coming soon but I can’t tell for sure when.
thx!
FYI: pygame 2.1.3 had just been released with support for Python 3.11. A bit thank you to the maintainers!
I think this can be closed.
Nice, I updated my pygame now.
C:\Users\Liu.D.H>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -U pygame Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pygame in c:\users\liu.d.h\appdata\local\programs\python\python311\lib\site-packages (2.1.3.dev8) Collecting pygame Downloading https://pypi.tuna.tsinghua.edu.cn/packages/23/c4/64a649c9c9dc649c8c01d7f1027c0656155fc48ba17e6fdd2cb38a993610/pygame-2.1.3-cp311-cp311-win_amd64.whl (10.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.4/10.4 MB 6.4 MB/s eta 0:00:00 Installing collected packages: pygame Attempting uninstall: pygame Found existing installation: pygame 2.1.3.dev8 Uninstalling pygame-2.1.3.dev8: Successfully uninstalled pygame-2.1.3.dev8 Successfully installed pygame-2.1.3 C:\Users\Liu.D.H>
Failed to install pygame. There is an error in pypm compilation, saying «too many initializers».
building ‘pygame.pypm’ extension C:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Iprebuilt-x64/SDL2-2.24.2/include -Iprebuilt-x64/include -Ic:\usr\dev\python\include -Ic:\usr\dev\python\Include -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\include -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\ATLMFC\include -IC:\usr\dev\msvs2022\VC\Auxiliary\VS\include «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt» «-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um» -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\include -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\ATLMFC\include -IC:\usr\dev\msvs2022\VC\Auxiliary\VS\include «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt» «-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um» -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\include -IC:\usr\dev\msvs2022\VC\Tools\MSVC\14.36.32532\ATLMFC\include -IC:\usr\dev\msvs2022\VC\Auxiliary\VS\include «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt» «-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt» «-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um» /Tcsrc_c/pypm.c /Fobuild\temp.win-amd64-pypy310\Release\src_c/pypm.obj /W3 /wd4142 /wd4996 /GF /Gy pypm.c src_c/pypm.c(3770): warning C4244: ‘function’: conversion from ‘Py_ssize_t’ to ‘int32_t’, possible loss of data
src_c/pypm.c(4767): warning C4113: ‘PtTimestamp (__cdecl *)()’ differs in parameter lists from ‘PmTimeProcPtr’
src_c/pypm.c(6342): error C2078: too many initializers
src_c/pypm.c(6340): error C2078: too many initializers
src_c/pypm.c(6454): error C2078: too many initializers
src_c/pypm.c(6452): error C2078: too many initializers
This is the only method that works for me.
pip install pygame==1.9.1release --allow-external pygame --allow-unverified pygame
—
These are the steps that lead me to this command (I put them so people finds it easily):
$ pip install pygame
Collecting pygame
Could not find any downloads that satisfy the requirement pygame
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pygame to allow).
No distributions at all found for pygame
Then, as suggestes I allow external:
$ pip install pygame --allow-external pygame
Collecting pygame
Could not find any downloads that satisfy the requirement pygame
Some insecure and unverifiable files were ignored (use --allow-unverified pygame to allow).
No distributions at all found for pygame
So I also allow unverifiable:
$ pip install pygame --allow-external pygame --allow-unverified pygame
Collecting pygame
pygame is potentially insecure and unverifiable.
HTTP error 400 while getting http://www.pygame.org/../../ftp/pygame-1.6.2.tar.bz2 (from http://www.pygame.org/download.shtml)
Could not install requirement pygame because of error 400 Client Error: Bad Request
Could not install requirement pygame because of HTTP error 400 Client Error: Bad Request for URL http://www.pygame.org/../../ftp/pygame-1.6.2.tar.bz2 (from http://www.pygame.org/download.shtml)
So, after a visit to http://www.pygame.org/download.shtml, I thought about adding the version number (1.9.1release is the currently stable one).
—
Hope it helps.
This article will tell you how to install the Python Pygame module correctly and how to fix the problems during the installation process.
1. Install Python Pygame Module Use The PIP Install Command.
- Open the terminal and run the command pip install pygame in it.
$ pip install pygame Collecting pygame Downloading pygame-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl (8.9 MB) |████████████████████████████████| 8.9 MB 1.2 MB/s Installing collected packages: pygame Successfully installed pygame-2.1.2
- Run the command pip show pygame to verify the module installation.
$ pip show pygame Name: pygame Version: 2.1.2 Summary: Python Game Development Home-page: https://www.pygame.org Author: A community project. Author-email: [email protected] License: LGPL Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages Requires: Required-by:
2. Install Python Pygame Module Use The Binary Installer File.
- Besides using the pip install command, we can also install it using the downloaded binary installer file.
- Go to the Pygame GitHub website to download the Pygame installer file that matches your OS and Python versions.
- Open a terminal and go to the Pygame installer downloaded directory.
- Run the command python -m pip install –user pygame-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl to install the Pygame from the installer file.
$ python -m pip install --user pygame-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl Processing ./pygame-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl Installing collected packages: pygame Successfully installed pygame-2.1.2
- Run the command python -m pygame –version to verify the installed Pygame moduel version.
$ python -m pygame --version pygame 2.1.2 (SDL 2.0.18, Python 3.7.3) Hello from the pygame community. https://www.pygame.org/contribute.html /Library/Frameworks/Python.framework/Versions/3.7/bin/python: No module named pygame.__main__; 'pygame' is a package and cannot be directly executed
3. How To Fix The ImportError: No module named ‘pygame’.
3.1 Question.
- I installed pygame 1.9.2 in Windows, and my python version is 3.5. But when I import the pygame module in the python source code, it shows the error ImportError: No module named ‘pygame’. How can I fix this error?
>>> import pygame Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import pygame ImportError: No module named 'pygame'
3.2 Answer1.
- Below are the steps to install Pygame 1.9.2 on Python 3.5.1 for Windows, you can try it.
- After you successfully install Python 3.5, you should write down the Python 3.5 installed folder for later use.
- Download the wheel file pygame-1.9.2a0-cp35-none-win32.whl and save it to the folder python35/Scripts.
- Open a dos window and cd to the python35/Scripts folder, then run the below command.
pip3 install pygame-1.9.2a0-cp35-none-win32.whl
- If you can not run the above command successfully, you can run the below command instead.
python -m pip install pygame-1.9.2a0-cp35-none-win32.whl
- Now when you import the pygame module, the error should disappear.
3.3 Answer2.
- I also meet such an error, but the reason is different.
- I installed multiple Python versions on my Windows, and I installed pygame library successfully into one of my Python versions.
- But my IDE used python interpreter does not contain the pygame library, so when I import pygame in my IDE the error is shown.
- After I select the python interpreter that has installed pygame library, the error disappear.
- wish this can help you too.
3.4 Answer3.
- This error happened when you do not install pygame successfully.
- Or you may have multiple Python versions installed, and pygame is installed in one of the python versions, but you import pygame in another python version.
- So you should make sure the pygame library has been installed in your python env, you can run the below command to check it.
(MyPythonEnv) C:\Users\zhaosong>pip show pygame Name: pygame Version: 2.1.2 Summary: Python Game Development Home-page: https://www.pygame.org Author: A community project. Author-email: [email protected] License: LGPL Location: c:\users\zhaosong\anaconda3\envs\mypythonenv\lib\site-packages Requires: Required-by:
4. How To Fix ERROR: Command errored out with exit status 1:…EOFError: EOF when reading a line When Install Pygame Using PIP.
4.1 Question.
- I run the command pip install pygame on windows 10, but it throws the error with the message ERROR: Command errored out with exit status 1:…EOFError: EOF when reading a line. My python version is 3.9. Below is the detailed error message. How can I fix it?
Collecting pygame Using cached pygame-1.9.6.tar.gz (3.2 MB) ERROR: Command errored out with exit status 1: command: 'c:\users\jerry\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\jerry\\AppData\\Local\\Temp\\pip-install-4b04m745\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\jerry\\AppData\\Local\\Temp\\pip-install-4b04m745\\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 'C:\Users\jerry\AppData\Local\Temp\pip-pip-egg-info-up4741kz' cwd: C:\Users\jerry\AppData\Local\Temp\pip-install-4b04m745\pygame\ Complete output (17 lines): WARNING, No "Setup" File Exists, Running "buildconfig/config.py" Using WINDOWS configuration... Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\jerry\AppData\Local\Temp\pip-install-4b04m745\pygame\setup.py", line 194, in <module> buildconfig.config.main(AUTO_CONFIG) File "C:\Users\jerry\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\config.py", line 210, in main deps = CFG.main(**kwds) File "C:\Users\jerry\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\config_win.py", line 576, in main and download_win_prebuilt.ask(**download_kwargs): File "C:\Users\jerry\AppData\Local\Temp\pip-install-4b04m745\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask reply = raw_input( EOFError: EOF when reading a line ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
4.2 Answer1.
- From the message you provide, we can see that you just install the Pygame version 1.9.6. And your python version is 3.9.
- But Pygame 1.9.6 does not support python 3.9 now. So you had better use python 3.8 instead.
- Or you can install Pygame 2.0 with the command pip install pygame==2.0.0, Pygame 2.0 support python 3.9.
- You can also download the Pygame wheel file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame, it contains the wheel file pygame‑1.9.6‑cp39‑cp39‑win32.whl that meet your needs.
Pygame — библиотека для программирования игр на языке Python. К сожалению, при установке pygame могут возникнуть ошибки. Их возможностей несколько и их причины могут быть различными. В этой статье мы рассмотрим несколько проверенных способов, которые помогут исправить ошибки при установке pygame.
Проверьте версию Python
Pygame работает только на определенной версии Python. Обычно на сайте Pygame указывается, с какой версией она совместима. При установке проверьте, установлена ли у вас подходящая версия Python.
Обновите pip
Pygame можно установить через pip — инструмент управления пакетами Python. Если вы столкнулись с ошибками при установке pygame, то попробуйте обновить pip.
python -m pip install -U pip
Установите зависимости
Pygame может требовать установки дополнительных зависимостей. Например, для работы SDL нужны заголовочные файлы C. Существуют пакеты, которые устанавливают SDL сразу с заголовочными файлами внутри. Но если вам нужно установить его вручную, то попробуйте следующие команды:
sudo apt-get install libsdl-dev
sudo apt-get install libsdl-image1.2-dev
sudo apt-get install libsdl-mixer1.2-dev
sudo apt-get install libsdl-ttf2.0-dev
Установите самую последнюю версию Pygame
Pygame постоянно обновляется, и последняя версия может иметь меньше ошибок, чем предыдущие. Убедитесь, что вы пытаетесь установить последнюю версию Pygame с помощью следующей команды:
python -m pip install pygame
Запустите установочный файл Pygame вручную
Если все проверенные способы выше не работают, попробуйте скачать Pygame вручную и установить его. Скачайте архив, распакуйте его и запустите установочный файл setup.py.
python setup.py install
Заключение
Теперь у вас есть несколько проверенных способов, чтобы исправить ошибки при установке Pygame. Если ни один из этих способов не работает, попробуйте обратиться за помощью к сообществу Python или Pygame. Удачи!