4

I'm making a real simple RPG game at college and I would like to use pygame. However, my college has a group policy disabling any Windows executables from running so I can't install pygame. Is there any way I can just import pygame by just having it in the same folder?

1
  • 2
    If you can't get @ViteFalcon's method to work and you're willing to try other packages besides pygame, check out pyglet, which can be imported without being installed. (If you're using a 64-bit Python, you may need to go with pyglet version 1.2, which is currently in alpha.) Commented Jan 17, 2013 at 21:45

2 Answers 2

5

One thing I do with external python libraries is to download the source, build it and copy the built library into ${PROJECT_HOME}/lib/${EXTERNAL_LIB_NAME}. This way, I can run my python scripts with just standard python installation on a machine. To be able to use the external lib, you'll have to include the lib directory to sys path like this:

import os
from sys import path as syspath
syspath.append(os.path.join(os.path.dirname(__file__), 'lib'))

P.S.: Since pygame has C/C++ files to be compiled, you'd have to use mingw instead. Refer to this answer for that: error: Unable to find vcvarsall.bat

EDIT: In case you're wondering how to build pygame from source, you'll need to run setup.py build. This will build the python library into 'build' folder of the package directory and there you'd see how it should be placed in Python's directory. You will face the compilation problem in Windows as I've mentioned before, but you can easily fix that.

EDIT 2: Download link to contents of 'lib' for PyGame:

Python 2.7: http://dl.dropbox.com/u/71422266/pygame27.7z

Python 3.2: http://dl.dropbox.com/u/71422266/pygame32.7z

Sign up to request clarification or add additional context in comments.

5 Comments

I've never done this before and i cant get this to work. installed mingw and it works fine however I cannot seem to get it to build as it throws an error "RuntimeError: The dependencies are linked to the wrong C runtime for Python 3.2". I really wanted to use pygame but i may have to use pyglet.
pyglet is Python wrappers to OpenGL. If you're looking to build a game, that's a bit low-level. I've updated the answer to include a link to download PyGame for 2.7. Unzip that into 'lib' directory of your project and use it as I've mentioned in the first part of my answer.
Thank you very much for the download, It works now. I use python 3.2 as you may have guessed and im not sure it matters but your code didn't work. i made it work by fiddling with it to get from sys import path as syspath syspath.append(syspath[0] + '\\lib')
@user1985217: Don't forget to accept this answer if it solved your problem, which it looks like it did.
@MightyMit: That code was for Python 2.7. It would different for 3.2 :)... Glad that you've got pygame works for you now
1

If you're allowed to run stuff from a USB drive, one option would be to use Portable Python 2.7.3.2, which includes PyGame 1.9.1.

1 Comment

Sadly I can't run executables from USB either. Thanks anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.