简体   繁体   中英

Using Pygame without installing

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?

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'))

PS: 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

如果你允许从USB驱动器运行东西,一种选择是使用Portable Python 2.7.3.2 ,其中包括PyGame 1.9.1。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM