Python Forum
Beginner stuck in Python book for kids
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner stuck in Python book for kids
#1
Hi,
100% beginner.
We bought this book called "Computer coding: Python Games for Kids".
It's supposed to teach Python in a simple and fun way.

The fun ended very soon however, because after following all the steps on how to install Pygame and Pygame Zero, and testing our very first and very simple piece of code, we are stuck in cmd with this message:
"pgzrun is not recognized as an internal or external command, operable program or batch file."

We've spent more than an hour on Google, trying to find solutions, and although some expert Python users refer to this issue, we have absolutely no idea what most of them are talking about (hence: 100% Beginner).
We tried one thing, which was 'adding the python directory to Path', which we did (without really knowing what it does), and which didn't solve the problem, everything is still exactly the same and we are back where we started Cry

Does anyone have a solution to this problem? Shy
Reply
#2
You need to show the code for us to help.
mic81k likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
The "code" is just a very simple test thingy at the start of the book, I don't think it'll tell you much.
It looks like this:

def draw():
screen.draw.text("Hello", topleft=(10, 10))

And we have to call this code hello.py and then we're supposed to open it in cmb, by doing this:
pgzrun C:\Users\myrealname\OneDrive\Desktop\python games\hello\hello.py

And cmd then replies with this:
pgzrun is not recognized as an internal or external command, operable program or batch file.

And then I'm like this: Huh Huh Huh
Reply
#4
That will not get you a pygame window or text display. I don't know about pygame zero. Never used it.
Here is a tutorial on pygame.
https://www.geeksforgeeks.org/pygame-tutorial
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#5
Usually if you are running a python program from cmd you start with "python -m " then the program path. What editor are you writing the program in? Did you install the packages as administrator?
Reply
#6
This worked for me
  • python3 -m pip install pgzero
  • created blank file intro.py
  • created a function called draw
  • ran from terminal pgzrun intro.py

def draw():
    screen.draw.text('Hello World!', (120,120), color='orange', fontsize=48)
Using IDLE or other IDEs
import pgzrun

def draw():
    screen.draw.text('Hello World!', (120,120), color='orange', fontsize=48)

pgzrun.go()
Output:

Attached Files

Thumbnail(s)
   
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#7
How did you install Python on your computer? Did you get it from the Microsoft store or did you install from Python.org? When you installed Python did you install as administrator or

Can you run python from the command line?

When you installed pygame zero did you install as administrator?
Reply
#8
Thank you for trying to help me.
When I try the same thing you did, I get this:

Attached Files

Thumbnail(s)
   
Reply
#9
(Nov-22-2023, 12:24 PM)deanhystad Wrote: How did you install Python on your computer? Did you get it from the Microsoft store or did you install from Python.org? When you installed Python did you install as administrator or

Can you run python from the command line?

When you installed pygame zero did you install as administrator?


I downloaded it from python.org and installed, but then it didn't work in cmd. Then I uninstalled it and installed it from Microsoft Store and that one works in cmd. I am administrator on this PC, so I assume I installed it as administrator. I also changed or added the directory to PATH, which was something I found on Google, but I don't know what that did, and it didn't solve the issue either.
Reply
#10
I tried something else and I can make it work now. But it doesn't work the way it's described in the book. When I open the hello.py file directly, it opens 2 windows, one that looks like cmd with the message ''hello from pygame...", and the other window has the word HELLO written in the top left corner. But the pgzrun hello.py command in cmd still gives a file not found error.

So I sort of "solved" it, without understanding a thing of what's going on here Sad

Attached Files

Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Deitel book "Python for Programmers" ricardian 7 23,301 May-12-2023, 01:33 PM
Last Post: snippsat
  best " Learning Python " book for a beginner alok 4 3,064 Jul-30-2021, 11:37 AM
Last Post: metulburr
  Nested Python functions (Dan Bader's book) Drone4four 4 2,585 Jun-26-2021, 07:54 AM
Last Post: ndc85430
  I really need help, I am new to python, I am using a book that helps me to learn JaprO 5 2,998 Nov-28-2020, 02:30 PM
Last Post: JaprO
  Stuck on python quiz challenge baesian 2 2,192 Aug-16-2020, 12:52 AM
Last Post: scidam
  creating an 'adress book' in python using dictionaries? apollo 6 14,834 May-06-2019, 12:03 PM
Last Post: snippsat
  Learning python, stuck on some code. stanceworksv8 2 3,490 Apr-02-2019, 01:51 AM
Last Post: stanceworksv8
  I'm teaching myself python and i'm stuck... stormrider 2 3,019 Dec-06-2017, 10:16 PM
Last Post: Larz60+
  I finsh the basics of python but I'm stuck on how to link code to GUI Qubayel 5 4,360 Apr-04-2017, 07:18 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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