Tag Archives: pygame

Python Error: [9880] failed to execute script [How to Solve]

1. When I was packing the game, the exe in dist flashes back. You can’t see what the error is.

After recording the screen with the video recorder, the error code is found as follows:

2. According to the error content, scoreboard There is a problem with line 18 of Py:

The cause of the error has been highlighted.

3. Problem-solving:

It is in the font setting “None”, can not be translated, so lead to error, change the “None” to the system font, here changed to ‘SimHei’

When checking the information, I found that other people encountered the problem: the path of the image. The relative path written is not correct, you have to write the absolute path.)

PS: At this point the game can still only be used on your own computer, also because of the picture path problem. The path on your own computer is not the same as the path on other people’s computers. To let others play too, you still have to change it.

[Solved] Pygame.error: mixer not initialized & pygame.error: WASAPI can‘t find requested audio endpoint: Could not Find the Element.

When developing games using python, we will inevitably use the pyGame module, which has a sound function. Using this function, we can add sound effects to our games.


Problem Description:

To use the sound module, we must initialize our game at the beginning of the main function, so we add the following statement at the beginning of the main function to initialize the game.

# Game initialization
    pygame.init()

However, when I run the program, I find that the game window flashes back and an error message appears, as follows:

D:\Game\TankWar\venv\Scripts\python.exe D:/Game/TankWar/main.py
pygame 2.0.2 (SDL 2.0.16, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "D:/Game/TankWar/main.py", line 41, in <module>
    is_quit_game = run_Game(config)
  File "D:/Game/TankWar/main.py", line 22, in run_Game
    sounds[key] = pygame.mixer.Sound(value)
pygame.error: mixer not initialized

Process finished with exit code 1

it says I didn’t initialize the mixer!!! We can’t help it. Let’s go according to his error report and initialize the mixer separately.

pygame.init()
pygame.mixer.init()

The following error message still appears, and the game window still flashes back.

D:\Game\TankWar\venv\Scripts\python.exe D:/Game/TankWar/main.py
pygame 2.0.2 (SDL 2.0.16, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "D:/Game/TankWar/main.py", line 42, in <module>
    is_quit_game = run_Game(config)
  File "D:/Game/TankWar/main.py", line 17, in run_Game
    pygame.mixer.init()
pygame.error: WASAPI can't find requested audio endpoint: Could not find the element.

Process finished with exit code 1

Solution:

After repeated tests, I found that it can run normally sometimes, and the above error reports will appear sometimes. Finally, I found a big man’s article and solved this problem.

earphone problem

Because I use a desktop computer and have no audio connected, there has been no audio output device, which causes pyGame to not know where to output the sound (in this case, the audio device cannot be found), resulting in an error. After inserting the audio device (i.e. my headset), it’s solved…

[Solved] Pygame Install Error: Command errored out with exit status 255: hg clone –noupdate -q https://bitbucket.o

report errors:

ERROR: Command errored out with exit status 255: hg clone –noupdate -q https://bitbucket.org/pygame/pygame /private/var/folders/jt/s0hr2mwx2f91p9xjm0r09vqr0000gn/T/pip-req-build-17brj_ kp Check the logs for full command output.

context:

Learn Python Programming: from introduction to practice. When you start the example practice in Chapter 12, you need to install the pyGame environment. You always report errors according to the methods in the book and cannot install normally.

terms of settlement:

Do not use the method in the book:
PIP3 install — user Hg+ https://bitbucket.org/pygame/pygame

Direct use

pip3 install pygame

I’m really good at installing it successfully

ERROR: pygame-1.9.2-cp35-cp35m-win32.whl is not a supported wheel on this platform.

Why?

The downloaded pyGame is not compatible with the python version.

How do you do it?

Go to the website and download the pyGame installation related to your Python version.
(check your Python version: if you enter Python in CMD, you will be prompted for the python version.)

Process:

When installing pyGame last night, I went to the website: link according to the process in the textbook “Python Programming: from introduction to practice”, and downloaded the corresponding pyGame. However, the above errors occurred during the installation.
Looking all over the network, there is no suitable solution for me.
Then I look at the error report carefully:
pygame-1.9.2-cp35-cp35m-win32.whl is not supported by this platform (wheel, please point out what it is). The previous file is used to install pyGame.
1.9.2 refers to PIP version.
Cp35 refers to Python version 3.5, while mine is 3.7.
So far, the event is clear. Each pyGame corresponds to a different version of Python. The version is incompatible and an error is reported.
After downloading, the installation is successful!
(no screenshots here: I forgot to cut them last night)

Python 3.7 pyGame download method


open https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

download pygame 1.9.3 – cp37 – cp37m – win_amd64. WHL

PIP install pygame-1.9.3-cp37-cp37m-win_amd64.whl

test type import pygame in python IDLE. If no error is reported, the installation is successful, and then type pygame.ver to see the version number

appear pygame.error : font not initialized problem, remember to check whether the program calls pygame.init ()

The pygame.init() function, which must be called after the pygame module is imported and before you start using any of the functions provided by PyGame, you don’t have to know what this function does, just know that in order to work with pyGame functions, you must call it at the beginning. If you run into an error like Pygame.error: font not initialized, check to see if you forgot to call Pygame.init () in front of your program