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

Started by
4 comments, last by swiftcoder 10 years, 11 months ago

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?

Advertisement

Do you have pygame installed?

Does it work when you use the interactive interpreter?

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.

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.

Are there any other versions of Python on your computer?

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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement