Module not found error pygame

I have installed python 3.3.2 and pygame 1.9.2a0. Whenever I try to import pygame by typing: import pygame I get following error message : Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03...

I have installed python 3.3.2 and pygame 1.9.2a0. Whenever I try to import pygame by typing:

import pygame

I get following error message :

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pygame
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pygame
ImportError: No module named 'pygame'
>>> 

I went through some of the questions related to this error but none of the solution helped.
I have 64 bit machine with Win7 OS

timrau's user avatar

timrau

22.4k4 gold badges52 silver badges64 bronze badges

asked Aug 19, 2013 at 15:26

user2398618's user avatar

5

go to python/scripts folder, open a command window to this path, type the
following:

C:python34scripts> python -m pip install pygame

To test it, open python IDE and type

import pygame

print (pygame.ver)

It worked for me…

LoukasPap's user avatar

answered May 4, 2017 at 9:33

Srikar Madhavapeddy's user avatar

3

Here are instructions for users with the newer Python 3.5 (Google brought me here, I suspect other 3.5 users might end up here as well):

I just successfully installed Pygame 1.9.2a0-cp35 on Windows and it runs with Python 3.5.1.

  • Install Python, and remember the install location
  • Go here and download pygame-1.9.2a0-cp35-none-win32.whl
  • Move the downloaded .whl file to your python35/Scripts directory
  • Open a command prompt in the Scripts directory (ShiftRight click in the directory > Open a command window here)
  • Enter the command:

    pip3 install pygame-1.9.2a0-cp35-none-win32.whl

  • If you get an error in the last step, try:

    python -m pip install pygame-1.9.2a0-cp35-none-win32.whl

And that should do it. Tested as working on Windows 10 64bit.

answered Apr 11, 2016 at 16:02

charlie's user avatar

charliecharlie

8461 gold badge11 silver badges17 bronze badges

3

I was trying to figure this out for at least an hour. And you’re right the problem is that the installation files are all for 32 bit.

Luckily I found a link to the 64 pygame download! Here it is: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Just pick the corresponding version according to your python version and it should work like magic. The installation feature will bring you to a bright-blue screen as the installation (at this point you know that the installation is correct for you.

Then go into the Python IDLE and type «import pygame» and you should not get any more errors.

Props go to @yuvi who shared the link with StackOverflow.

answered May 1, 2014 at 23:27

aaron-coding's user avatar

aaron-codingaaron-coding

2,5211 gold badge22 silver badges31 bronze badges

5

  1. open the folder where your python is installed
  2. open scripts folder
  3. type cmd in the address bar. It opens a command prompt window in that location
  4. type pip install pygame and press enter
  5. it should download and install pygame module
  6. now run your code. It works fine :-)

answered Dec 28, 2017 at 5:42

NARENDER REDDY's user avatar

I had the same problem and discovered that Pygame doesn’t work for Python3 at least on the Mac OS, but I also have Tython2 installed in my computer as you probably do too, so when I use Pygame, I switch the path so that it uses python2 instead of python3. I use Sublime Text as my text editor so I just go to
Tools > Build Systems > New Build System and enter the following:

{
    "cmd": ["/usr/local/bin/python", "-u", "$file"],    
}

instead of

{
    "cmd": ["/usr/local/bin/python3", "-u", "$file"],   
}

in my case. And when I’m not using pygame, I simply change the path back so that I can use Python3.

General Failure's user avatar

answered Dec 26, 2016 at 6:34

Megan Chang's user avatar

The current PyGame release, 1.9.6 doesn’t support Python 3.9. I fyou don’t want to wait for PyGame 2.0, you have to use Python 3.8. Alternatively, you can install a developer version by explicitly specifying the version (2.0.0.dev20 is the latest release at the time of writing):

pip install pygame==2.0.0.dev20

or try to install a pre-release version by enabling the --pre option:

pip install pygame --pre

answered Oct 23, 2020 at 5:51

Rabbid76's user avatar

Rabbid76Rabbid76

196k25 gold badges121 silver badges164 bronze badges

Resolved !

Here is an example

C:UsersuserAppDataLocalProgramsPythonPython36-32Scripts>pip install pygame

John's user avatar

John

2,5034 gold badges18 silver badges33 bronze badges

answered Nov 29, 2019 at 16:43

diego lara's user avatar

try this in your command prompt:
python -m pip install pygame

Oscar Nguyen's user avatar

answered Feb 18, 2021 at 17:21

Ace Standard's user avatar

I was getting the same error. It is because your version of Pygame is not compatible with your version of Python or Pydev. Go to this link and get the proper version of Pygame for your current version of Python. Ctrl F to find it faster or click on the word python in blue. up at the top. While you instal Pygame it should find the Python path by itself. At least mind did any ways. I run Pygame through Eclipse with Python 3.4.

http://www.lfd.uci.edu/~gohlke/pythonlibs/

answered Nov 14, 2014 at 2:20

TriGeo's user avatar

TriGeoTriGeo

351 silver badge6 bronze badges

1

Since no answer stated this:

Make sure that, if you are using a virtual environment, you have activated it before trying to run the program.

If you don’t really know if you are using a virtual environment or not, check with the other contributors of the project. Or maybe try to find a file with the name activate like this: find . -name activate.

answered May 31, 2017 at 8:08

user2089810's user avatar

  1. Install and download pygame .whl file.
  2. Move .whl file to your python35/Scripts
  3. Go to cmd
  4. Change directory to python scripts
  5. Type:

    pip install pygame
    

Here is an example:

C:UsersuserAppDataLocalProgramsPythonPython36-32Scripts>pip install pygame

Stephen Rauch's user avatar

Stephen Rauch

46.7k31 gold badges109 silver badges131 bronze badges

answered Dec 14, 2017 at 3:35

EDGE 074's user avatar

I just encountered the same problem and found that I am having multiple interpreters of the different versions installed in my system and pygame got installed in one of them when I installed it using command but in my IDE another interpreter was selected so this messed up my system, try to see if you are also having the same situation.

answered Jun 26, 2021 at 15:47

Tanishq chandra's user avatar

Just use this command in the terminal python3 -m pip install -U pygame --user

answered Sep 22, 2022 at 14:51

Eduardo-Puentes's user avatar

You don’t need 64 bit Python on Win64 system, just install the 32bit versions of both Python and Pygame and they will work just fine (and there is a ton more modules for them anyways).

answered Aug 18, 2014 at 21:58

KalELonRedKryptonite's user avatar

3

I’m using the PyCharm IDE. I could get Pygame to work with IDLE but not with PyCharm. This video helped me install Pygame through PyCharm.

(It seems that PyCharm only recognizes a package; if you use its GUI.)

However, there were a few slight differences for me; because I’m using Windows instead of a Mac.

My “preferences” menu is found in: File->Settings…

Then, in the next screen, I expanded my project menu, and clicked Project Interpreter. Then I clicked the green plus icon to the right to get to the Available Packages screen.

answered Mar 6, 2018 at 12:34

Joe's user avatar

JoeJoe

8,0113 gold badges17 silver badges23 bronze badges

I ran into the error a few days ago! Thankfully, I found the answer.

You see, the problem is that pygame comes in a .whl (wheel) file/package. So, as a result, you have to pip install it.

Pip installing is a very tricky process, so please be careful. The steps are:-

Step1. Go to C:/Python (whatever version you are using)/Scripts. Scroll down. If you see a file named pip.exe, then that means that you are in the right folder. Copy the path.

Step2. In your computer, search for Environment Variables. You should see an option labeled ‘Edit the System Environment Variables’. Click on it.

Step3. There, you should see a dialogue box appear. Click ‘Environment Variables’. Click on ‘Path’. Then, click ‘New’. Paste the path that you copies earlier.

Step4. Click ‘Ok’.

Step5. Shift + Right Click wherever your pygame is installed. Select ‘Open Command Window Here’ from the dropdown menu. Type in ‘pip install py’ then click tab and the full file name should fill in. Then, press Enter, and you’re ready to go! Now you shouldn’t get the error again!!!

answered Aug 28, 2018 at 21:39

First execute python3 then type the command import pygame,now you can see the output

answered Apr 16, 2020 at 11:06

brean's user avatar

breanbrean

7572 gold badges9 silver badges17 bronze badges

For this you have to install pygame package from the cmd (on Windows) or from terminal (on mac). Just type pip install pygame
.If it doesn’t work for you, then try using this statement pip3 install pygame .
If it is still showing an error then you don’t have pip installed on your device and try installing pip first.

answered Aug 21, 2020 at 20:04

Ansh's user avatar

AnshAnsh

686 bronze badges

make sure if you are on windows that your library directory is added to path

answered Aug 14, 2021 at 9:21

dragon445's user avatar

dragon445dragon445

1211 silver badge4 bronze badges

This may happen when pygame didn’t installed, install the pygame first

pip
pip install pygame

if dont work update the PIP by goto python install folder and type

python -m pip install --upgrade pip

hope it work

answered Aug 26, 2021 at 12:24

Azka Hamidzan F.'s user avatar

Try this solution:
Type in to cmd (Windows):

C:Users'Your name'> pip install -U pygame

You should remove python -m, py -m, python3 -m before the pip
Also remove --user behind it.

It will said:

C:Usersviait>pip install -U pygame
Defaulting to user installation because normal site-packages is not writeable
Collecting pygame
  Downloading pygame-2.1.2-cp310-cp310-win_amd64.whl (8.4 MB)
     ---------------------------------------- 8.4/8.4 MB 1.7 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.1.2

Then test it in your IDE or cmd:
(CMD example)

C:Usersviait>python
Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.1.2 (SDL 2.0.18, Python 3.10.3)
Hello from the pygame community. https://www.pygame.org/contribute.html

(IDE example)

import pygame

You can do this without any errors.

answered Apr 5, 2022 at 9:17

Oscar Nguyen's user avatar

You could use

pip install pygame

but if you use IDE like PyCharm, then you could just either install it from Python Packages or use right click at the package name then left click on Show Context Actions then left click on Install package pygame

(Personally, I recommended using Python Packages for the package installing because it has documentation with it)

answered Nov 26, 2022 at 10:42

Foryxled_Dev's user avatar

You gotta use Pycharm and install it in Terminal using pip install pygame and also after that enter Pycharm and hover on pygame in the «Import pygame» and in Pycharm it will tell you to download that and you can easily download it and enjoy your result

answered Jun 4, 2021 at 14:13

Mushfiqur Rahman's user avatar

I was having the same trouble and I did

pip install pygame

and that worked for me!

answered Nov 30, 2016 at 18:38

TheHyperCake's user avatar

Posted by Marta on October 4, 2021 Viewed 37237 times

Card image cap

Hey there! In this article I will show you why you might encounter the error modulenotfounderror: no module named ‘pygame’ when you are creating a game using the python library pygame. You will also learn how to fix this error so you can continue working on your game.

The pygame module provides functionality to create a graphical display, work with graphics, and read from input devices, like mouse and keyboard, on multiple platforms. 

This module is a third-party module; therefore, the Python installation doesn’t include it by default. As a result, you need to install it separately. It is quite simple to install; you can find how in one of the sections below. Without further to do, let’s get started! 

How to check pygame is installed.

Probably you are facing the following situation. You wrote a small program using pygame, included all imports, installed python; however, when you execute the program, you see the error:

Traceback (most recent call last):
  File line 1, in <module>
    import random, pygame, sys
ModuleNotFoundError: No module named 'pygame'

This error means that the pygame module is not installed. Another option is that you have several python versions installed on your machine. It could be installed in a different python installation(python SDK) and not installed in the python installation you are using to execute the game.

Therefore, the first thing to tackle this problem is finding out if the module is installed. Whether you are using Mac or Windows, you can check if a module is installed using the pip tool. Pip is the package manager that python uses to keep track of all libraries installed. To check the list of installed libraries, you can run the following:

Output:

py==1.8.1
pyasn1==0.4.5
pygame==1.9.4
pygubu==0.9.8.6
pyparsing==2.4.7
pytest==5.4.1

After running the pip freeze command, you will see the list of all python libraries installed on your machine. Now you can double-check if the pygame library is installed.

How to install pygame on mac

Let’s say you check your installed libraries using pip freeze, and you noticed the library list doesn’t include the pygame library. What’s next? You need to install the module using pip. All you need to do is executing the command below:

How to Fix When working from an IDE

Another possible scenario. It could be that you installed the module from the terminal; however, when you execute the game from your IDE, such as PyCharm, you still get the error.

In case you are working on mac, one possible reason is that your IDE is set up to use python 2. Python 2 is installed on the Mac operating system by default.

As a result, if you installed python 3, you have two python installations(python SDKs) in your machine. And your IDE should be set up to use python3, which includes pip as the “module/package manager.” Or the python SDK where the module is installed. Let’s see how to do that.

Modulenotfounderror: no module named 'pygame'

In Pycharm, go to File->Project Structure and check the project SDK. The project SDK indicates the Python installation that pycharm uses to execute your python scripts.

If there is “No SDK” selected, make sure you coose python 3. If python3 is not available in the dropdown, click on “New …” and add the Python SDK( or installation), using the path where you have installed python earlier.

In other words, you need to make your IDE point to the same python SDK, where you have installed the module.

Where is your python SDK?

In case you don’t know or don’t remember where you installed python, no problem. Pretty simple to find out. You can check just by executing the following command from your terminal:

Output:

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

The above line indicates where python is installed on your machine. The Python SDK will access any module through the pip manager that is part of the SDK. As a result, you should make sure your python command and pip are in the same location/path, which means they are part of the same SDK

Where is pip installed?

You can find out where pip is installed using the which command as well. As I mentioned earlier, make sure python and pip are in the same location, meaning they belong to the same SDK. Check the pip location using the command below:

Output:

/Library/Frameworks/Python.framework/Versions/3.7/bin/pip

The above output means the pip command is installed in the location above, and it is part of the python version 3.7.

Conclusion

In conclusion, you will encounter the error Modulenotfounderror: no module named ‘pygame’ for two main reasons. One is that the module is not installed. The other reason is that you installed the module in a different python SDK to the one you are using to executing your game.

I hope you enjoy the article, and thank you so much for reading and supporting this blog. Happy Coding!

More Interesting articles

Modulenotfounderror: no module named 'pygame'
python errors
return statement
dfs in python

A common error you may encounter when using Python is modulenotfounderror: no module named ‘pygame’. This error occurs when Python cannot detect the pygame library in your current environment, and Pygame does not come with the default Python installation. This tutorial goes through the exact steps to troubleshoot this error for the Windows, Mac and Linux operating systems.

ModuleNotFoundError: no module named ‘pygame’

What is ModuleNotFoundError?

The ModuleNotFoundError occurs when the module you want to use is not present in your Python environment. There are several causes of the modulenotfounderror:

The module’s name is incorrect, in which case you have to check the name of the module you tried to import. Let’s try to import the re module with a double e to see what happens:

import ree
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
1 import ree

ModuleNotFoundError: No module named 'ree'

To solve this error, ensure the module name is correct. Let’s look at the revised code:

import re

print(re.__version__)
2.2.1

You may want to import a local module file, but the module is not in the same directory. Let’s look at an example package with a script and a local module to import. Let’s look at the following steps to perform from your terminal:

mkdir example_package

cd example_package

mkdir folder_1

cd folder_1

vi module.py

Note that we use Vim to create the module.py file in this example. You can use your preferred file editor, such as Emacs or Atom. In module.py, we will import the re module and define a simple function that prints the re version:

import re

def print_re_version():

    print(re.__version__)

Close the module.py, then complete the following commands from your terminal:

cd ../

vi script.py

Inside script.py, we will try to import the module we created.

import module

if __name__ == '__main__':

    mod.print_re_version()

Let’s run python script.py from the terminal to see what happens:

Traceback (most recent call last):
  File "script.py", line 1, in <module>
    import module
ModuleNotFoundError: No module named 'module'

To solve this error, we need to point to the correct path to module.py, which is inside folder_1. Let’s look at the revised code:

import folder_1.module as mod

if __name__ == '__main__':

    mod.print_re_version()

When we run python script.py, we will get the following result:

2.2.1

Lastly, you can encounter the modulenotfounderror when you import a module that is not present in your Python environment.

What is pygame?

Pygame (stylized as pygame) is a set of Python modules for writing video games. It is highly portable and runs on every platform and operating system, and Pygame does not automatically come installed with Python. The simplest way to install pygame is to use the package manager for Python called pip. The following instructions to install pygame are for the major Python version 3.

How to install pygame on Windows Operating System

First, you need to download and install Python on your PC. Ensure you select the install launcher for all users and Add Python to PATH checkboxes. The latter ensures the interpreter is in the execution path. Pip is automatically on Windows for Python versions 2.7.9+ and 3.4+.

You can check your Python version with the following command:

python3 --version

You can install pip on Windows by downloading the installation package, opening the command line and launching the installer. You can install pip via the CMD prompt by running the following command.

python get-pip.py

You may need to run the command prompt as administrator. Check whether the installation has been successful by typing.

pip --version

To install pygame with pip, run the following command from the command prompt.

pip3 install pygame

How to install pygame on Mac Operating System

Open a terminal by pressing command (⌘) + Space Bar to open the Spotlight search. Type in terminal and press enter. To get pip, first ensure you have installed Python3. You can use the package manager Homebrew to do this. To install Homebrew, run the following command from your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Follow the steps and prompts before the installation starts, then insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Alternatively, if you have OS X 10.12 (Sierra) or older, use:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

You can check that you have Python 3 installed on your system by running:

python3 --version
Python 3.8.8

Download pip by running the following curl command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

The curl command allows you to specify a direct download link, and using the -o option sets the name of the downloaded file.

Install pip by running:

python3 get-pip.py

From the terminal, use pip3 to install pygame:

pip3 install pygame

How to install pygame on Linux Operating System

All major Linux distributions have Python installed by default. However, you will need to install pip. You can install pip from the terminal, but the installation instructions depend on the Linux distribution you are using. You will need root privileges to install pip. Open a terminal and use the commands relevant to your Linux distribution to install pip.

Installing pip for Ubuntu, Debian, and Linux Mint

sudo apt install python-pip3

Installing pip for CentOS 8 (and newer), Fedora, and Red Hat

sudo dnf install python-pip3

Installing pip for CentOS 6 and 7, and older versions of Red Hat

sudo yum install epel-release

sudo yum install python-pip3

Installing pip for Arch Linux and Manjaro

sudo pacman -S python-pip

Installing pip for OpenSUSE

sudo zypper python3-pip

Once you have installed pip, you can install pygame using:

pip3 install pygame

Check pygame Version

Once you have successfully installed pygame, you can use two methods to check the version of pygame. First, you can use pip show from your terminal.

pip show pygame
Name: pygame
Version: 2.1.2
Summary: Python Game Development

Second, within your python program, you can import pygame and then reference the __version__ attribute:

import pygame

print(pygame.__version__)
2.1.2

Installing pygame Using Anaconda

Anaconda is a distribution of Python and R for scientific computing and data science. You can install Anaconda by going to the installation instructions. Once you have installed Anaconda, you can install pygame using the following command:

conda install -c cogsci pygame

Summary

Congratulations on reading to the end of this tutorial. The modulenotfounderror occurs if you misspell the module name, incorrectly point to the module path or do not have the module installed in your Python environment. If you do not have the module installed in your Python environment, you can use pip to install the package. However, you must ensure you have pip installed on your system. You can also install Anaconda on your system and use the conda install command to install the pygame library.

For further reading on installing data science and machine learning libraries, you can go to the articles:

  • OpenCV: How to Solve Python ModuleNotFoundError: no module named ‘cv2’
  • Requests: How to Solve Python ModuleNotFoundError: no module named ‘requests’
  • Pandas: How to Solve Python ModuleNotFoundError: no module named ‘pandas’
  • Matplotlib: How to Solve Python ModuleNotFoundError: no module named ‘matplotlib’
  • Flask: How to Solve Python ModuleNotFoundError: no module named ‘flask’

Go to the online courses page on Python to learn more about Python for data science and machine learning.

Have fun and happy researching!

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.

  1. 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
    
  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.

  1. Besides using the pip install command, we can also install it using the downloaded binary installer file.
  2. Go to the Pygame GitHub website to download the Pygame installer file that matches your OS and Python versions.
  3. Open a terminal and go to the Pygame installer downloaded directory.
  4. 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
    
  5. 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.

  1. 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.

  1. Below are the steps to install Pygame 1.9.2 on Python 3.5.1 for Windows, you can try it.
  2. After you successfully install Python 3.5, you should write down the Python 3.5 installed folder for later use.
  3. Download the wheel file pygame-1.9.2a0-cp35-none-win32.whl and save it to the folder python35/Scripts.
  4. 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
  5. 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
  6. Now when you import the pygame module, the error should disappear.

3.3 Answer2.

  1. I also meet such an error, but the reason is different.
  2. I installed multiple Python versions on my Windows, and I installed pygame library successfully into one of my Python versions.
  3. But my IDE used python interpreter does not contain the pygame library, so when I import pygame in my IDE the error is shown.
  4. After I select the python interpreter that has installed pygame library, the error disappear.
  5. wish this can help you too.

3.4 Answer3.

  1. This error happened when you do not install pygame successfully.
  2. 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.
  3. 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:Userszhaosong>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:userszhaosonganaconda3envsmypythonenvlibsite-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.

  1. 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:usersjerryappdatalocalprogramspythonpython39python.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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:UsersjerryAppDataLocalTemppip-pip-egg-info-up4741kz'
             cwd: C:UsersjerryAppDataLocalTemppip-install-4b04m745pygame
        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:UsersjerryAppDataLocalTemppip-install-4b04m745pygamesetup.py", line 194, in <module>
            buildconfig.config.main(AUTO_CONFIG)
          File "C:UsersjerryAppDataLocalTemppip-install-4b04m745pygamebuildconfigconfig.py", line 210, in main
            deps = CFG.main(**kwds)
          File "C:UsersjerryAppDataLocalTemppip-install-4b04m745pygamebuildconfigconfig_win.py", line 576, in main
            and download_win_prebuilt.ask(**download_kwargs):
          File "C:UsersjerryAppDataLocalTemppip-install-4b04m745pygamebuildconfigdownload_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.

  1. 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.
  2. But Pygame 1.9.6 does not support python 3.9 now. So you had better use python 3.8 instead.
  3. Or you can install Pygame 2.0 with the command pip install pygame==2.0.0, Pygame 2.0 support python 3.9.
  4. 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.

Содержание

  1. failed loading libmpg123-0.dll also after reinstall #2647
  2. Comments
  3. Cause
  4. PyInstaller EXE can’t find libmpg123-0.dll #2450
  5. Comments
  6. Pygame error failed loading libmpg123 0 dll не найден указанный модуль
  7. Вопрос:
  8. Ответ №1:
  9. Комментарии:
  10. libmpg123-0.dll
  11. Как исправить ошибку Libmpg123-0.dll?
  12. What is a DLL file, and why you receive DLL errors?
  13. Когда появляется отсутствующая ошибка Libmpg123-0.dll?
  14. метод 1: Скачать Libmpg123-0.dll и установить вручную
  15. Libmpg123-0.dll Версии
  16. метод 2: Исправление Libmpg123-0.dll автоматически с помощью инструмента для исправления ошибок
  17. метод 3: Установка или переустановка пакета Microsoft Visual C ++ Redistributable Package
  18. метод 4: Переустановить программу
  19. метод 5: Сканируйте систему на наличие вредоносного ПО и вирусов
  20. метод 6: Использовать очиститель реестра
  21. pygame.error: Failed loading libmpg123-0.dll about auto-maple HOT 3 CLOSED
  22. Comments (3)
  23. Related Issues (20)
  24. Recommend Projects
  25. React
  26. Vue.js
  27. Typescript
  28. TensorFlow
  29. Django
  30. Laravel
  31. Recommend Topics
  32. javascript
  33. server
  34. Machine learning
  35. Visualization
  36. Recommend Org
  37. Facebook
  38. Microsoft

failed loading libmpg123-0.dll also after reinstall #2647

pycham error : failed loading libmpg123-0.dll

The text was updated successfully, but these errors were encountered:

Not enough information, closing it now

Hi @MightyJosip,
I am able to reproduce the issue without using PyCharm as well, found the root cause, possible solution and interim workaround for @raghav3148 and other affected users until fix is released.

The full error message, that i believe is the same also when using PyCharm, is:

pygame.error: Failed loading libmpg123-0.dll: The specified module could not be found.

Cause

Related to bpo-36085 on how the DLL loading is handled by Python interpreter on Windows.
As noted in the change logs but better described in Python’s 3.8 What’s New

DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely. Only the system paths, the directory containing the DLL or PYD file, and directories added with add_dll_directory() are searched for load-time dependencies.
Specifically, PATH and the current working directory are no longer used, and modifications to these will no longer have any effect on normal DLL resolution.
If your application relies on these mechanisms, you should check for add_dll_directory() and if it exists, use it to add your DLLs directory while loading your library.
Note that Windows 7 users will need to ensure that Windows Update KB2533623 has been installed (this is also verified by the installer). (Contributed by Steve Dower in bpo-36085.)

Источник

PyInstaller EXE can’t find libmpg123-0.dll #2450

Environment:

You can get some of this info from the text that pops up in the console when you run a pygame program.

  • Operating system (e.g. Windows, Linux (Debian), Linux (Ubuntu), Mac): Windows
  • Python version (e.g. 3.7.9, 3.8.5): 3.9.0
  • SDL version (e.g. SDL 2.0.12): SDL 2.0.14
  • PyGame version (e.g. 2.0.0.dev10, 1.9.6): 2.0.1
  • Relevant hardware (e.g. if reporting a bug about a controller, tell us the brand & name of it): IDK

Current behavior:

When running a pygame EXE with audio made with PyInstaller, it doesn’t run, instead throwing an error: Failed loading libmpg123-0.dll: The specified module could not be found.

Expected behavior:

It runs with no errors.

Steps to reproduce:

Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application.
if the bug is caused by a specific file (image, font, sound, level, please upload it as an attachment

  1. Make a pygame script with audio.
  2. Compile it with PyInstaller.
  3. Run the EXE.

Test code

If possible add a simple test program that shows the problem described in this report.

Stack trace

The text was updated successfully, but these errors were encountered:

Источник

Pygame error failed loading libmpg123 0 dll не найден указанный модуль

#python #windows #pygame #windows-10

#python #Windows #pygame #windows-10

Вопрос:

Мы пытаемся запустить метод music.load() pygame в нашем коде. Мы запускаем наш файл через командную строку Windows [CMD]. Мы продолжаем получать эту ошибку, что-нибудь помогает 🙂

  • windows 10
  • python3.9
  • приведенный ниже код не представляет полный файл

Ответ №1:

Сегодня у меня была похожая проблема, но мне удалось ее решить. Я пролистал несколько страниц результатов Google, но там было всего несколько результатов, посвященных этой теме, что показалось мне странным, пока я не понял, что все они были за последние пару недель. Это заставило меня поверить, что эта проблема не обязательно связана с моим кодом, а является ошибкой в недавнем обновлении pygame. Похоже, разработчики изменили что-то, что сломало микшер, поскольку я попытался вернуться к более старой версии pygame, и это сработало потрясающе. В любом случае, может быть, это TMI, просто подумал, что поделюсь своим процессом.

TL; DR: Кажется, что-то было изменено в недавнем обновлении pygame, которое нарушило работу микшера pygame. Возврат к предыдущей версии модуля с использованием приведенных ниже шагов, по-видимому, является функциональным временным обходным путем, пока они все уладят.

  1. pip uninstall pygame
  2. pip install pygame==1.9.6 (В настоящее время я использую 1.9.6; я не знаю, какие другие версии работают)

Комментарии:

1. Большое спасибо, мы попробуем этот процесс и посмотрим, как он работает. Мы очень ценим вашу помощь!

Источник

libmpg123-0.dll

Смотрите дополнительную информацию о Outbyte и универсальные приборы. Пожалуйста, просмотрите Outbyte EULA и Политика конфиденциальности

Как исправить ошибку Libmpg123-0.dll?

Прежде всего, стоит понять, почему libmpg123-0.dll файл отсутствует и почему возникают libmpg123-0.dll ошибки. Широко распространены ситуации, когда программное обеспечение не работает из-за недостатков в .dll-файлах.

What is a DLL file, and why you receive DLL errors?

DLL (Dynamic-Link Libraries) — это общие библиотеки в Microsoft Windows, реализованные корпорацией Microsoft. Файлы DLL не менее важны, чем файлы с расширением EXE, а реализовать DLL-архивы без утилит с расширением .exe просто невозможно.:

Когда появляется отсутствующая ошибка Libmpg123-0.dll?

Если вы видите эти сообщения, то у вас проблемы с Libmpg123-0.dll:

  • Программа не запускается, потому что Libmpg123-0.dll отсутствует на вашем компьютере.
  • Libmpg123-0.dll пропала.
  • Libmpg123-0.dll не найдена.
  • Libmpg123-0.dll пропала с вашего компьютера. Попробуйте переустановить программу, чтобы исправить эту проблему.
  • «Это приложение не запустилось из-за того, что Libmpg123-0.dll не была найдена. Переустановка приложения может исправить эту проблему.»

Но что делать, когда возникают проблемы при запуске программы? В данном случае проблема с Libmpg123-0.dll. Вот несколько способов быстро и навсегда устранить эту ошибку.:

метод 1: Скачать Libmpg123-0.dll и установить вручную

Прежде всего, вам нужно скачать Libmpg123-0.dll на ПК с нашего сайта.

  • Скопируйте файл в директорию установки программы после того, как он пропустит DLL-файл.
  • Или переместить файл DLL в директорию вашей системы (C:WindowsSystem32, и на 64 бита в C:WindowsSysWOW64).
  • Теперь нужно перезагрузить компьютер.

Если этот метод не помогает и вы видите такие сообщения — «libmpg123-0.dll Missing» или «libmpg123-0.dll Not Found,» перейдите к следующему шагу.

Libmpg123-0.dll Версии

Размер файла: 0.14 MB

Версия

0.0.0.0

метод 2: Исправление Libmpg123-0.dll автоматически с помощью инструмента для исправления ошибок

Как показывает практика, ошибка вызвана непреднамеренным удалением файла Libmpg123-0.dll, что приводит к аварийному завершению работы приложений. Вредоносные программы и заражения ими приводят к тому, что Libmpg123-0.dll вместе с остальными системными файлами становится поврежденной.

Вы можете исправить Libmpg123-0.dll автоматически с помощью инструмента для исправления ошибок! Такое устройство предназначено для восстановления поврежденных/удаленных файлов в папках Windows. Установите его, запустите, и программа автоматически исправит ваши Libmpg123-0.dll проблемы.

Если этот метод не помогает, переходите к следующему шагу.

метод 3: Установка или переустановка пакета Microsoft Visual C ++ Redistributable Package

Ошибка Libmpg123-0.dll также может появиться из-за пакета Microsoft Visual C++ Redistribtable Package. Необходимо проверить наличие обновлений и переустановить программное обеспечение. Для этого воспользуйтесь поиском Windows Updates. Найдя пакет Microsoft Visual C++ Redistributable Package, вы можете обновить его или удалить устаревшую версию и переустановить программу.

  • Нажмите клавишу с логотипом Windows на клавиатуре — выберите Панель управления — просмотрите категории — нажмите на кнопку Uninstall.
  • Проверить версию Microsoft Visual C++ Redistributable — удалить старую версию.
  • Повторить деинсталляцию с остальной частью Microsoft Visual C++ Redistributable.
  • Вы можете установить с официального сайта Microsoft третью версию редистрибутива 2015 года Visual C++ Redistribtable.
  • После загрузки установочного файла запустите его и установите на свой ПК.
  • Перезагрузите компьютер после успешной установки.

Если этот метод не помогает, перейдите к следующему шагу.

метод 4: Переустановить программу

Как только конкретная программа начинает давать сбой из-за отсутствия .DLL файла, переустановите программу так, чтобы проблема была безопасно решена.

Если этот метод не помогает, перейдите к следующему шагу.

метод 5: Сканируйте систему на наличие вредоносного ПО и вирусов

System File Checker (SFC) — утилита в Windows, позволяющая пользователям сканировать системные файлы Windows на наличие повреждений и восстанавливать их. Данное руководство описывает, как запустить утилиту System File Checker (SFC.exe) для сканирования системных файлов и восстановления отсутствующих или поврежденных системных файлов (включая файлы .DLL). Если файл Windows Resource Protection (WRP) отсутствует или поврежден, Windows может вести себя не так, как ожидалось. Например, некоторые функции Windows могут не работать или Windows может выйти из строя. Опция «sfc scannow» является одним из нескольких специальных переключателей, доступных с помощью команды sfc, команды командной строки, используемой для запуска System File Checker. Чтобы запустить её, сначала откройте командную строку, введя «командную строку» в поле «Поиск», щелкните правой кнопкой мыши на «Командная строка», а затем выберите «Запустить от имени администратора» из выпадающего меню, чтобы запустить командную строку с правами администратора. Вы должны запустить повышенную командную строку, чтобы иметь возможность выполнить сканирование SFC.

  • Запустите полное сканирование системы за счет антивирусной программы. Не полагайтесь только на Windows Defender. Лучше выбирать дополнительные антивирусные программы параллельно.
  • После обнаружения угрозы необходимо переустановить программу, отображающую данное уведомление. В большинстве случаев, необходимо переустановить программу так, чтобы проблема сразу же исчезла.
  • Попробуйте выполнить восстановление при запуске системы, если все вышеперечисленные шаги не помогают.
  • В крайнем случае переустановите операционную систему Windows.

В окне командной строки введите «sfc /scannow» и нажмите Enter на клавиатуре для выполнения этой команды. Программа System File Checker запустится и должна занять некоторое время (около 15 минут). Подождите, пока процесс сканирования завершится, и перезагрузите компьютер, чтобы убедиться, что вы все еще получаете ошибку «Программа не может запуститься из-за ошибки Libmpg123-0.dll отсутствует на вашем компьютере.

метод 6: Использовать очиститель реестра

Registry Cleaner — мощная утилита, которая может очищать ненужные файлы, исправлять проблемы реестра, выяснять причины медленной работы ПК и устранять их. Программа идеально подходит для работы на ПК. Люди с правами администратора могут быстро сканировать и затем очищать реестр.

  • Загрузите приложение в операционную систему Windows.
  • Теперь установите программу и запустите ее. Утилита автоматически очистит и исправит проблемные места на вашем компьютере.

Если этот метод не помогает, переходите к следующему шагу.

Источник

pygame.error: Failed loading libmpg123-0.dll about auto-maple HOT 3 CLOSED

Not entirely sure if this will fix your issue, but
Did you download CUDNN and put the bin files into CUDA’s bin directory.
This is where CUDA was installed by default on my system C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6bin
Also If youre using CUDA 11, CUDNN needs to be 8.1.x

hmyay commented on January 16, 2023

you have pygame 2.1.2 not 1.9.6 which is working for auto-maple.

dev-milani commented on January 16, 2023

Hello how are you?

I’ll leave the solution below that for my case solved:

1 — Go to the directory where pygame is installed and find the file «libmpg123-0.dll».
On my computer it is in the following directory, but on yours it will be in another: «C:UsersFelipePycharmProjectsPythonExerciciosvenvLibsite-packagespygame» (yours will be the same from the venv folder);
2 — Copy the «libmpg123-0.dll» file;
3 — Go to the system32 folder — «C:WindowsSystem32» and paste the «libmpg123-0.dll» file;
4 — Go to the SysWOW64 folder — «C:WindowsSysWOW64» and paste the «libmpg123-0.dll» file;
5 — Restart the system;

This was the only way that worked for me, hope it helps you.

  • Player cannot walk to rune
  • Unable to open cmd
  • Unable to get minimap set up HOT 1
  • command book for zero?
  • how to utilise only opencv for rune?
  • Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found HOT 1
  • Question about the macro.
  • Rune get me crash
  • Boss map in Arcana
  • Rune not solving HOT 1
  • Adele: Character just walks or «turtles» instead of performance command at recorded locations HOT 1
  • DOSE THIS BOT WORKS HOT 2
  • What is the bets way to create routine to use skill when it is not on cooldown? HOT 1
  • Lie detector alert
  • AttributeError? HOT 1
  • Unable to detect minimap
  • Game closing when starting a routine HOT 1
  • cv2 inrange and problem with new Arrow
  • rune problem HOT 2
  • is there a way to make the green bubbles smaller HOT 1

Recommend Projects

React

A declarative, efficient, and flexible JavaScript library for building user interfaces.

Vue.js

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Typescript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

TensorFlow

An Open Source Machine Learning Framework for Everyone

Django

The Web framework for perfectionists with deadlines.

Laravel

A PHP framework for web artisans

Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

javascript

JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

Some thing interesting about web. New door for the world.

server

A server is a program made to process requests and deliver data to clients.

Machine learning

Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

Visualization

Some thing interesting about visualization, use data art

Some thing interesting about game, make everyone happy.

Recommend Org

Facebook

We are working to build community through open source technology. NB: members must have two-factor auth.

Microsoft

Open source projects and samples from Microsoft.

Источник

  • #1

Traceback (most recent call last):
File «C:UsersмаксимDocumentsпрограммы питон2_pygame_draw.py», line 2, in <module>
import pygame
ModuleNotFoundError: No module named ‘pygame.
Если надо то могу скинуть код который я добавил.

  • #3

написало что pip не является внутренней или внешней программой в cmd

  • #4

добавьте в path
или переустановите питон, поставив галочку ADD PATH

  • #5

добавьте в path
или переустановите питон, поставив галочку ADD PATH

WARNING: You are using pip version 20.2.3; however, version 22.0.3 is available.
You should consider upgrading via the ‘c:usersмаксимappdatalocalprogramspythonpython38python.exe -m pip install —upgrade pip’ command. Выдало после того как инсталлировался pygame

  • #6

добавьте в path
или переустановите питон, поставив галочку ADD PATH

Все решено, спасибо за ответ.

Понравилась статья? Поделить с друзьями:
  • Module not found error no module named pip
  • Module not found error no module named numpy
  • Module library initialization error
  • Module isapimodule notification executerequesthandler handler 1c web service extension error code 0x800700c1
  • Module initialization error http сервис