r/pythonhelp • • Feb 17 '22

Problems Downloading Pygme

I've been trying to download Pygame for a while now. I've tried on three separate computers, and they've all given me the same error message, so I assume I'm doing something wrong. I have the latest version of python installed, and when I did so, I was sure to tick the little box labelled 'pip'. However, when I type 'pip install pygame' into the shell, it gives:

pip install pygame

SyntaxError: invalid syntax

The spoiler is there to indicate what's highlighted. This might be a pygame problem, rather than a python problem, but asking here can't help. So... what am I doing wrong? I've looked about, and no one seems to have the same problem as me, so it feels like I'm making some obvious mistake, but I'd appreciate any help y'alls can give

EDIT: I have since solved the problem. Thanks for all your help.

3 Upvotes

21 comments sorted by

1

u/MT1961 Feb 17 '22

Sounds like it is running some other program called pip. You might try running pip --version. It will tell you what version you are running and where it is found (if it is running Python's pip).

1

u/The_Gobinator Feb 17 '22

>>> pip --version

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

NameError: name 'pip' is not defined. Did you mean: 'zip'?

>>>

It doesn't seem to be defined, have I maybe not included pip when I downloaded python? I'd be amazed if so, I remember distinctly ticking that little box...

1

u/MT1961 Feb 17 '22

You seem to be running pip in the Python shell, you'd need to import pip to use it that way. However, from the command line, it should work (outside Python).

1

u/The_Gobinator Feb 17 '22 edited Feb 17 '22

I'm pretty sure It's the command line. It's black with white text, and all that. How would I go about importing pip?

EDIT: Ok, I may not have been using the command line, as I have since learnt. I put in the actual command line, and it seems to have downloaded something, although when I tried to run some python code that imported pygame, it told me there was no file named pygame. I feel I'm close, but there' evidently something I need to do.

1

u/MT1961 Feb 17 '22

The Python shell will always show >>> at the beginning, so I'm fairly sure that's where you are.

You can import anything in the shell in the usual manner:
import pip

The thing is, I don't think that's doing what you want, you want it installed in the package cache. Open a plain CMD window (assuming windows), and type pip --version. See what happens.

1

u/The_Gobinator Feb 17 '22

It gives me this:

C:\Users\peter>pip --version

pip 22.0.3 from C:\Users\peter\AppData\Roaming\Python\Python310\site-packages\pip (python 3.10)

as a side-note, I wish it were easier for me to know when you've responded, since reddit can't notify me without me refreshing the page...

1

u/MT1961 Feb 17 '22

Okay, that part looks fine. And yes, the whole reddit not updating thing is annoying.

You are using a very new version of Python/pip, I suppose that could be the problem. Pip is clearly working, can you install anything else?

1

u/The_Gobinator Feb 17 '22

like what?

1

u/MT1961 Feb 17 '22

Try installing requests, for example:

pip install requests

See whether it is just pip, or whether it is a problem with pygame on your system.

1

u/The_Gobinator Feb 17 '22

It spat this out:

C:\Users\peter>pip install requests

Defaulting to user installation because normal site-packages is not writeable

Collecting requests

Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)

---------------------------------------- 63.1/63.1 KB 3.3 MB/s eta 0:00:00

Collecting idna<4,>=2.5

Downloading idna-3.3-py3-none-any.whl (61 kB)

---------------------------------------- 61.2/61.2 KB ? eta 0:00:00

Collecting charset-normalizer~=2.0.0

Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)

Collecting certifi>=2017.4.17

Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)

---------------------------------------- 149.2/149.2 KB 9.3 MB/s eta 0:00:00

Collecting urllib3<1.27,>=1.21.1

Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)

---------------------------------------- 138.7/138.7 KB ? eta 0:00:00

Installing collected packages: certifi, urllib3, idna, charset-normalizer, requests

WARNING: The script normalizer.exe is installed in 'C:\Users\<my name>\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed certifi-2021.10.8 charset-normalizer-2.0.12 idna-3.3 requests-2.27.1 urllib3-1.26.8

C:\Users\<my name>>

not sure what that means, but it was in some very pretty colours.

→ More replies (0)