Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add pygame module in PyCharm IDE

I've downloaded pygame-1.9.1release.tar.gz from the Pygame website. I extracted and installed it and it's working fine in the command line Python interpreter in Terminal (Ubuntu). But I want to install it for some IDE, like PyCharm. How can I do it?

like image 348
lavee_singh Avatar asked Feb 11 '15 12:02

lavee_singh


People also ask

Why does PyCharm Say No module named pygame?

The main or root cause for getting this modulenotfound error is that you have not installed pygame in your system. And another reason is your python interpreter has not known the path of the package installed. You will get the red underline below the package name if you try to import pygame package in pycharm.

Why is pygame module not found?

The Python "ModuleNotFoundError: No module named 'pygame'" occurs when we forget to install the pygame module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pygame command.


2 Answers

Well, you don't have to download it for PyCharm here. You probably know how it checks your code. Through the interpreter! You don't need to use complex command lines or anything like that. You need to is:

  • Download the appropriate interpreter with PyGame included

  • Open your PyCharm IDE (Make sure it is up to date)

  • Go to File

  • Press Settings (Or Ctrl + Alt + S)

  • Double click on the option that looks like Project: Name_of_Project

  • Click on Project Interpreter

  • Choose the interpreter you want to use that includes PyGame as a module

  • Save your options

And you are ready to go! Here is an alternate (I have never done this, please try to test it)

  • Add PyGame in the same folder as your PyCharm file (Your PyCharm stuff is always in a specific file placed by you during installation/upgrade) Please consider putting your PyCharm stuff inside a folder for easy access.

I hope this helps you!

like image 98
Anthony Pham Avatar answered Nov 06 '22 06:11

Anthony Pham


For PyCharm 2017 do the following:

  • File - Settings
  • Double click on your project name
  • Select Project Interpreter
  • Click on green + button on the right side of the window
  • Type Pygame in search window
  • Click Install package.

Not I'm saying that the answers above won't work, but it might be frustrating to a newbie to do command line magic.

like image 35
Sergey K Avatar answered Nov 06 '22 06:11

Sergey K