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

View all comments

Show parent comments

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.

1

u/MT1961 Feb 17 '22

I can't say I've ever really cared for the colors. To each their own.

Try installing pygame to the user directory (add --user to the command line: pip install --user pygame). Might just be a permissions issue.

1

u/The_Gobinator Feb 17 '22

Requirement already satisfied: pygame in c:\users\<my name>\appdata\roaming\python\python310\site-packages (2.1.2)

seems it's already downloaded.

Which is odd, because python still thinks there's 'no module named pygame'.

1

u/MT1961 Feb 17 '22

Weird. If you go into a Python shell and just type import pygame, does it produce the same error? Not really sure, although I know I've seen this error before from other people.

1

u/The_Gobinator Feb 17 '22

import pygame

Traceback (most recent call last):

File "<pyshell#3>", line 1, in <module>

import pygame

ModuleNotFoundError: No module named 'pygame'

Glad to hear that it's not something really simple I'm overlooking.

1

u/MT1961 Feb 17 '22

Probably should have asked this earlier. What are you using for your Python environment? PyCharm, Visual Code, IDLE?

1

u/The_Gobinator Feb 17 '22

Pretty sure it's IDLE

1

u/MT1961 Feb 17 '22

Hm. You might close down your Python environment, and restart it. In some cases, it doesn't reload stuff when you do it outside the editor/environment. Beyond that, I really don't have a clue. It LOOKS like it loaded. pip list will tell you what it thinks is loaded.

1

u/The_Gobinator Feb 17 '22

huh

I probably should've expected that. Turn it off and turn it on again. I'll give it a go.

1

u/MT1961 Feb 17 '22

Well, you know, I've been in IT for a long time. Listen, if that doesn't work, re-install the operating system ...

→ More replies (0)