Error importing pygame into Pycharm

Asked

Viewed 2,318 times

1

I am here only because it has been a week that I try in every way to install the pygame in Pycharm and I’m not getting it. I’ve tried it from the command line and several ways, but when I can install it, an error appears.

The error that appears when I can install is this:

[d: build libmpg123 mpg123-1.25.10 src libmpg123 id3.c:482] error: No comment text / Valid Description?

The other error that appears and does not let install is this:

Traceback (Most recent call last): File "C:/Users/Rafael/Pycharmprojects/exercicios/ex021.py", line 1, in import pygame Modulenotfounderror: No module named 'pygame'

I’m just doing a simple exercise where I want to play an mp3 file. Below is the code:

import pygame
pygame.init()
pygame.mixer.music.load('ex021.mp3')
pygame.mixer.music.play()
pygame.event.wait()

I’ve tried for the pip install pygame, I’ve tried clicking the red light right on Pycharm himself, I’ve tried settings - project interpreter, Anyway, I believe it’s some version incompatibility.

I’m using Windows, Python 3.8.2 PIP 20.0.2 and the pygame that I’m trying to install is the pygame 1.9.6 Can someone help me, please?

5 answers

1

I managed to solve this by specifying the pygame library using mixer:

from pygame import mixer
mixer.init()

mixer.music.load('Hoist.mp3')
mixer.music.play()
input('Agora você escuta?')

0

Simionato, try downloading pygame on: https://pypi.python.org/pypi/pygame

Select the option pygame-1.9.3-cp35-cp35m-Win32. whl

In the Python installation folder (C: Users Seuusuario Appdata Local Programs Python Python"Scripts" version), put the file that has been downloaded.

Access the Python folder via CMD and update the Pip with the following command line: python -m Pip install --upgrade Pip.

Still in CMD, type cd Scripts and type enter; Install pygame, with the Pip install pygame-1.9.3-cp35-cp35m-Win32 command. whl

  • Thank you so much for the help, I haven’t been able to, I haven’t found the file you gave me of pygame-1.9.3-cp35-cp35m-Win32. whl (in my case I think it would be 64,)anyway, when typing cd Scripts, also does not find anything... But I tried all that in the race today, but I couldn’t... Tomorrow I’ll try again... Thank you so much for your help. Big hug.

  • As for not being able to access the folder, was your Python installed via direct download or by Anaconda? You can try the below: v64 https://files.pythonhosted.org/packages/45/a5/580578790aa2f8f274855d45b4c89ffb910f1c72ddb754873b2ae8d7fc7f/pygame-1.9.6-cp35m-win_amd64.whl V32 https://files.pythonhosted.org/packages/6d/ca/6c54a92efc66efc66ef33e78cb003148c637debd3a85eb44a8d93df19c1f2f9c6/pygame-1.9.6-cp35cp35m-win32whl

0

I was able to solve the pygame problem in Pycharm 3.8.5. Go to: File>Sttings>Project:"the name of your project">Python Interpreter> In Package, click +> now look in the left corner of the screen that will open in the search magnifying glass: pygame. Now just click install Package. READY!!!

0

I figured it out. In the folder of your project in Pycharm, delete the "interpreter" folder and go back to Pycharm > Settings > Project: Namesedproject > Project Interpreter and add another "interpreter". And then just add the pygame, either by the terminal, "cd directories of the project... Interpreter Scripts > Pip install pygame" or the same Pycharm interface.

-3

Bro, I went through the same pygame installation error, but I managed to fix by installing by Pip.

It goes like this: 1) opens cmd as administrator 2) executes the Pip list command 3) If you have pygame installed you run: Pip Uninstall pygame 4) and install again: Pip install pygame 5) Pip list again to see if installed 6) runs python IDLE code to see if it works

Browser other questions tagged

You are not signed in. Login or sign up in order to post.