ImportError: No module named pygame

Prabodh Prasad 1 Reputation point
2021-05-24T12:43:01.65+00:00

I 'm a programmer and I make games. I most commonly use pygame. But on VS code it gives me a 'ImportError: No module named pygame' error. The rest of the web says that I'm using python 2, but I have python 3.9, the image below for proof:

I've Tried running it with Python IDLE and it works, I even used the 'pip freeze' command and it it shows pygame in the list. I even tried uninstalling pygame and reinstalling it, but it doesn't work.

Thanks in advance

Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,441 Reputation points Microsoft External Staff
    2021-05-25T07:32:49.57+00:00

    Hello @Prabodh Prasad ,

    Welcome to Microsoft Q&A forum.

    Perhaps you need to try to switch and select python3 to use it(cause the module may be installed in python3). Please kindly follow this document: Using Python environments in VS Code to switch and select python3.

    BTW, since Visual Studio Code is different from Visual Studio, and our forum(Microsoft Q&A vs-general) is about Visual Studio IDE, you can post your issue on Stack Overflow for technical support.

    Hope this helps and thanks for your understanding.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.