pypkm /

Filename Size Date modified Message
20 B
0 B
1.5 KB
3.0 KB
4.6 KB

PyPKM - Pokémon File Manipulation


PyPKM is a Python package for creating, editing, and manipulating individual Pokémon file data (commonly referred to as PKM or .pkm files). The goal of this project is to allow a cross-platform way to easily work with these files.

PyPKM supports generation IV and generation V PKM files.


To install PyPKM, download and unarchive the package from its git repository. Then, you can either cd into the newly-created directory and run python install to install in your global Python path, or you can enter the directory and manually copy the pypkm subdirectory to a place in your Python path.


First, import the pypkm package:

import pypkm

Then, create or load a PKM file (making sure to specify the file's game generation):

# Create from scratch
my_pkm =

# Load from a file
my_pkm = pypkm.load(gen=4, path='MyPokemon.pkm')

# Load from data
pkm_data = open('/path/to/MyPokemon.pkm', 'r').read()
my_pkm = pypkm.load(gen=4, data=pkm_data)

From here, you can edit your Pokémon's data by calling attributes of the my_pkm instance. For example, to give your Pokémon the Leftovers item to hold:

my_pkm.item = 234

To teach your Pokémon the Roar of Time move:

my_pkm.move1 = 459

To see your Pokémon trainer's secret ID:

# 65534

You might even want to change your Pokémon's species all together: = 94

As you can tell, you need to know the correct index number for most editing. A proper API reference will be made available in time. Until then, refer to the appropriate function's documentation in the pypkm.attr module.

If you've edited the data, you probably want to save. If you've created the Pokémon from scratch or loaded directly from data and did not specify a path to save, you must do so now:'/path/to/NewPokemon.pkm')

If you loaded data from a file and optionally do not specify a path, PyPKM will create a new file in the same directory as the old to avoid overwriting the old data:
# MyPokemon_new.pkm


If you'd like to contribute, you can do so at my git repository. I'd love to hear any bugs or feature requests you have.


Many thanks to the folks at Project Pokemon for all of their research into the structure of Pokémon data.

A big thanks to Stephen Anthony Uy for his pycrypto module. Somehow I came across this module whilst looking for a way to encrypt and decrypt Pokémon data, and it's been a huge help (the shuffle() function comes directly from his work).

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.