问题
As a caveat, I have searched and tried every solution on could find on this topic here, on YouTube and anywhere google brought me to.
Running Windows 10 Home 64 bit and Python 3.6.4.
Pygame is displaying as an available module when I call a list of all modules via print (help('modules') ). But when I import it I get:
from pygame.base import *
ModuleNotFoundError: No module named 'pygame.base'
or
help('pygame') problem in pygame - ModuleNotFoundError: No module named 'pygame.base'
I have have installed pygame: PS C:\Users\mando\AppData\Local\Programs\Python\Python36-32\Scripts> py -m pip install pygame --user Requirement already satisfied: pygame in c:\users\mando\appdata\roaming\python\python36\site-packages You are using pip version 9.0.1, however version 9.0.3 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. PS C:\Users\mando\AppData\Local\Programs\Python\Python36-32\Scripts> m pip install --upgrade pip
I have updated pip as recommended: PS C:\Users\mando\AppData\Local\Programs\Python\Python36-32\Scripts> python -m pip install --upgrade pip Requirement already up-to-date: pip in c:\users\mando\appdata\local\programs\python\python36-32\lib\site-packages PS C:\Users\mando\AppData\Local\Programs\Python\Python36-32\Scripts>
I have installed both 32 and 64 bit whl for kicks, but none work: pygame-1.9.3-cp36-cp36m-win_amd64.whl
When I install this I get: pygame-1.9.3-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
I installed this via cmd running as an administrator.
I can actually run: py -m pygame.examples.aliens The application opens and runs fine. I just cannot import pygame into IDLE.
Can anyone please point me to a solution?
回答1:
Found the issue. The book I am using said to use: py -m pip install pygame --user. That installed it in the wrong path. The correct command is: pip install pygame. I deleted the pygame files and reinstalled them with pip install pygame and all is well now. Thanks @NekoTony. We'll chalk this one up to user error. –
来源:https://stackoverflow.com/questions/49713337/pygame-not-importing-in-python-3-6-4