-1

when I try to pip install pygame it tells me that the requirement is already satisfied, but when i try to import it, it gives me an error.

I tried importing pygame and expected it to work but it didn't. image where it shows that I can't import pygame

  • 3
    [Please don't post images of code/data/errors.](https://meta.stackoverflow.com/q/285551) You can [edit](https://stackoverflow.com/posts/i76822077/edit) your question and replace the images with [properly formatted](https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks) text. See: [*How to ask a good question*](https://stackoverflow.com/help/how-to-ask) – Woodford Aug 02 '23 at 17:19
  • 2
    What's the error when you try to import it? The screenshot just shows a warning (yellow underline). If you're getting an `ImportError`, that's one thing, but if it's a linter message, that's another. Please [edit] to add the details. – wjandrea Aug 02 '23 at 17:22
  • BTW, welcome to Stack Overflow! Check out the [tour], and [ask] for more tips. – wjandrea Aug 02 '23 at 17:22
  • 1
    Possible duplicate: [VS code can't import module which is already installed](/q/64172961/4518341) or even [Unable to import a module that is definitely installed](/q/14295680/4518341) – wjandrea Aug 02 '23 at 17:28
  • To clarify, I meant a linter message about an "unused import/name". Although, it's also possible to get something like "module not found" if the linter is misconfigured. – wjandrea Aug 02 '23 at 17:31

2 Answers2

0

Verify that the Python interpreter you are using is the same one where pygame is installed.

Run the following command:

which python

Try uninstalling pygame first and then reinstall it.

Run the following commands:

pip uninstall pygame
pip install pygame

Try Restarting the Interpreter or Environment

  • Restart vscode

Good Luck

  • 1
    "Try Restarting the Interpreter or Environment" -- huh? How would you do that? – wjandrea Aug 02 '23 at 18:09
  • 1
    After installing or reinstalling pygame, restart the Python interpreter or your development environment (e.g. VSCode) to ensure that the changes take effect. – moses mccabe Aug 08 '23 at 19:49
0

i suggest you to use a dev env manager like "anaconda" which allows you to look for every installed packages, you can still try to close and reopen the vs studio code file since vs code is reads the the list of packages when the project is first open.