• Advertisement
Sign in to follow this  

How to use pygame when running python through sublime text 2?

This topic is 1725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Every time I try to run a program that imports pygame through Sublime Text it says: ImportError: No module named pygame.

 

How do I import pygame if I'm running the file on Sublime Text?

 

Share this post


Link to post
Share on other sites
Advertisement

Do you have pygame installed?

 

Does it work when you use the interactive interpreter?

Edited by renega_666

Share this post


Link to post
Share on other sites

Your pygame folder needs to be installed in the folder where your current python version is installed. Here is my setup:

 

C:\Python27\include\pygame\

 

When you install pygame it will ask you to select the version of python to install to. You also need to verify that C:\Python27 is in your path system variable if you are using windows.

Share this post


Link to post
Share on other sites

I have pygame installed.  I have no idea where the files went or how to find them.  There is no include folder in my Python 2.7 folder.  I'm running Python 2.7 on a mac 10.8 os x.

 

Pygame works in IDLE just not when I try to launch it through Sublime Text.

Edited by ZorionBakar

Share this post


Link to post
Share on other sites

Are there any other versions of Python on your computer?

Share this post


Link to post
Share on other sites

My guess would be that Sublime's console uses its packaged copy of Python 3.x, rather than the system Python (which was Python 2.7, last I checked).

 

If I am correct, then you would need to figure out which directory Sublime keeps its python extensions in, and install a Python 3.x-compatible version of PyGame to that directory.

Edited by swiftcoder

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement