Reputation: 11
When I code this pygame import, it doesn't work with spyder:
import pygame
Window_width=700
Window_hight=500
pygame.init()
size= (Window_width, Window_hight)
screen= pygame.display.set_mode(size)
pygame.display.set_caption("Game")
pygame.quit()
The answer of spyder is :
>Python 2.7.14 |Anaconda, Inc.| (default, Nov 8 2017, 13:40:45) [MSC v.1500
64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
>File "C:/Users/hpinko/Desktop/python scripts/game.py", line 1, in <module>
import pygame
ImportError: No module named pygame
Please, help me to fix this.
Upvotes: 0
Views: 31363
Reputation: 1
I had the same issue but I followed Tom's advice and used CMD to navigate to the Scripts folder. Then I went to https://www.pygame.org/wiki/GettingStarted and used py -m pip install -U pygame --user for windows installation.
Upvotes: 0
Reputation: 93
It might be because pygame module is not installed on your pc. You can install it by using pip.
Step 1: Go to the directory in which python is installed on command prompt by using cd c:\Python27\
.
Step 2: Go to scripts folder by entering the command cd Scripts
. You might want to add this folder to your path variable to avoid navigating to c:\python27\Scripts
folder every time you want to install a package
Step 3: Install pygame by running pip install pygame
Upvotes: 1