Python Forum
pygame installation problems
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pygame installation problems
#1
Hello everyone,

I'm completely new to the Python language or to coding whatsoever. I'm following a guide done by Rob Miles called "Begin to code with Python", at the moment I'm learning how to install and add Pygame library using python shell. I use Windows 10 for this.
I started by opening Windows PowerShell and typing "py -m pip install pygame --user", there were no problems with that, it even gave me the option to update to the last version and I did so.

Apparently after that I should be able to write "import snaps import * " in Python IDLE to import all the functions in the snaps library, but there is where I get the error, a window pops up saying "invalid syntax" and the secont "import" is highlighted in red. If i only try to import snaps I get this error "ModuleNotFoundError: No module named 'snaps'".

It does says that if I want to use snaps in other folders, simply copy the file snaps.py into the folder, funny enough that file does not exist anywhere in my computer.

I know that pygame is installed and working because if I run "py -m pygame.examples.aliens" in the windows PowerShell, I'm able to play the aliens game.

I've tried to google in diferent ways but I didn't find anyone with my same problem, and I'm not able to figure it out as I don't fully understand how this programs work.

Sorry for the massive text. Thanks in advance!
RockBlok likes this post
Reply
#2
snaps appears to be a pygame wrapper handling some boilerplate pygame code for you. at least thats what it looks like from
https://github.com/Begintocodewithpython...n/snaps.py

If your going to import that module then you need save that snaps file in the same directory as your other code and import that as well as install pygame.
RockBlok likes this post
Recommended Tutorials:
Reply
#3
Are you by chance using "Begin to Code with Python" by Rob Miles?

I had the same error up until a few minutes ago, so I thought I'd drop you an answer in case you're still having this problem or for anyone who comes across this thread.

After searching for way too long, I realized that snaps isn't something that comes with pygame or python.

- You have to go to their website at aka.ms/BeginCodePython/downloads
- Download their sample zip file, which contains the example programs from the book.
- Unzip the folder.
- Go into samples-master.
- Then "Ch 03 Python Program Structure".
- Finally there you will find the elusive snaps.py file.

copy this over to the same folder that holds the py file trying to import it, and it should work.

mine didn't work at first, until I closed the shell and relaunched it.

I hope this helps!
RockBlok and neronhat like this post
Reply
#4
(Dec-12-2018, 07:05 AM)Aikanwha Wrote: Are you by chance using "Begin to Code with Python" by Rob Miles?

I had the same error up until a few minutes ago, so I thought I'd drop you an answer in case you're still having this problem or for anyone who comes across this thread.

After searching for way too long, I realized that snaps isn't something that comes with pygame or python.

- You have to go to their website at aka.ms/BeginCodePython/downloads
- Download their sample zip file, which contains the example programs from the book.
- Unzip the folder.
- Go into samples-master.
- Then "Ch 03 Python Program Structure".
- Finally there you will find the elusive snaps.py file.

copy this over to the same folder that holds the py file trying to import it, and it should work.

mine didn't work at first, until I closed the shell and relaunched it.

I hope this helps!
Larz60+ write Oct-29-2023, 09:34 AM:
Did you forget post context?
RockBlok likes this post
Reply
#5
(Dec-12-2018, 07:05 AM)Aikanwha Wrote: Are you by chance using "Begin to Code with Python" by Rob Miles?

I had the same error up until a few minutes ago, so I thought I'd drop you an answer in case you're still having this problem or for anyone who comes across this thread.

After searching for way too long, I realized that snaps isn't something that comes with pygame or python.

- You have to go to their website at aka.ms/BeginCodePython/downloads
- Download their sample zip file, which contains the example programs from the book.
- Unzip the folder.
- Go into samples-master.
- Then "Ch 03 Python Program Structure".
- Finally there you will find the elusive snaps.py file.

copy this over to the same folder that holds the py file trying to import it, and it should work.

mine didn't work at first, until I closed the shell and relaunched it.

I hope this helps!
I want to ask, does that mean snaps is just a library written by someone? So it cannot be imported directly like official libraries like time, random,.. ? Think
RockBlok likes this post
Reply
#6
(Oct-28-2023, 11:29 AM)neronhat Wrote:
(Dec-12-2018, 07:05 AM)Aikanwha Wrote: Are you by chance using "Begin to Code with Python" by Rob Miles?

I had the same error up until a few minutes ago, so I thought I'd drop you an answer in case you're still having this problem or for anyone who comes across this thread.

After searching for way too long, I realized that snaps isn't something that comes with pygame or python.

- You have to go to their website at aka.ms/BeginCodePython/downloads
- Download their sample zip file, which contains the example programs from the book.
- Unzip the folder.
- Go into samples-master.
- Then "Ch 03 Python Program Structure".
- Finally there you will find the elusive snaps.py file.

copy this over to the same folder that holds the py file trying to import it, and it should work.

mine didn't work at first, until I closed the shell and relaunched it.

I hope this helps!
I want to ask, does that mean snaps is just a library written by someone? So it cannot be imported directly like official libraries like time, random,.. ? Think

Hi, I'm also using this book and the answer to your question is yes according to the author :
Quote:Snaps functions

The snaps library is a Python program file held in the same folder as the example pro-
grams for each chapter. The file contains all the functions we’ll use. If you want to use

snaps in another folder, simply copy the file snaps.py into the folder.
chapter 3 p66
And as Aikanwha said, to use it you need to download it and then put it in the same folder as your python file
RockBlok likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Problems with jump code in pygame Joningstone 4 5,271 Aug-23-2021, 08:23 PM
Last Post: deanhystad
  (HELP GREATLY APPRECIATED) New user- Huge Pygame Installation Problem! Jbomb 1 2,782 Jan-12-2021, 07:32 PM
Last Post: MK_CodingSpace
  [Pygame] Problems with my textbox SheeppOSU 1 3,038 May-27-2019, 12:03 AM
Last Post: metulburr
  [pygame] Inventory problems. Weapons equipped to wrong slot SheeppOSU 6 3,942 May-07-2019, 02:46 AM
Last Post: SheeppOSU
  drawing, moving, and collision problems (pygame) SheeppOSU 26 14,438 Apr-22-2019, 03:09 AM
Last Post: SheeppOSU
  Problems with loading buttons (pygame) SheeppOSU 2 3,054 Apr-12-2019, 08:04 PM
Last Post: SheeppOSU
  [PyGame] Why didn't my installation of pygame work? JohnJSal 4 4,382 Jul-01-2018, 08:26 PM
Last Post: JohnJSal
  [PyGame] Installation problems leap 4 6,703 Jan-09-2017, 11:26 PM
Last Post: leap

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020