question

PrabodhPrasad-7771 avatar image
0 Votes"
PrabodhPrasad-7771 asked PrabodhPrasad-7771 commented

ImportError: No module named pygame

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:

[1]: /answers/storage/attachments/99139-screenshot-674.png


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


vs-general
screenshot-674.png (22.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered PrabodhPrasad-7771 commented

Hello @PrabodhPrasad-7771 ,

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @TianyuSun-MSFT, Pygame was installed for Python 3.9 and the VS Code environment was set as Python 2, Thanks again

0 Votes 0 ·