0

I can't start PyGame Zero window from cmd. According to book I bought my kid, I suppose to start it with

pgzrun test.py

Unfortunteally what I get is:

'pgzrun' is not recognized as an internal or external command,
operable program or batch file.

As a Python begginer I started with checking my python and pygame lib:

C:\Users\mikol\OneDrive\python\examples\asteroids>python --version
Python 3.10.9

C:\Users\mikol\OneDrive\python\examples\asteroids>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: pygame@pygame.org
License: LGPL
Location: c:\users\mikol\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages

I have also double confirmed adding

c:\users\mikol\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages

to PATH variable (using Win 11). Am I missing something?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Tomek
  • 701
  • 2
  • 8
  • 20

2 Answers2

0

Add the line import pgzrun in your top line of code. Then pgzrun.go() as your last line. This will run the python file using pygame.

ShadowCrafter_01
  • 533
  • 4
  • 19
PacMan
  • 1
0

Installing pgzero in an Administrator command prompt will ensure that pgzrun is available in the Windows path, by placing it in the location "C:\Program Files\Python311\Scripts\pgzrun.exe". If you install the module in a non-administrator command prompt, the pgzrun.exe file is installed under your roaming profile under a folder like this "C:\Users\username-here\AppData\Roaming\Python\Python311\Scripts".

If you have already installed pgzero in a non-administrator prompt, you'll have to uninstall it first using "pip uninstall" before re-installing from an administrator prompt.

Following the above instructions will allow running pgzrun from the command prompt as the OP was expecting.

riaann
  • 1