skillfed

pefile

Python PE parsing module

pefile v2024.8.26 8.4M downloads/30d#1,629 on PyPI2,061
Permissive license MIT Active released

What it is and what it does

pefile is a pure-Python library for reading and analyzing Portable Executable (PE) files, the binary format underlying Windows executables, DLLs, and system libraries. It exposes PE internal structures—headers, sections, import/export tables, resources—as object attributes with both uppercase names for raw structures and lowercase names for processed elements like the import table. The library is designed to handle real-world edge cases including corrupted, malformed, and malware-obfuscated PE files that may violate the standard format.

The package has no runtime dependencies and installs as a pure Python wheel, making it lightweight and portable. It supports Python 3.6 and later, is actively maintained with recent commits, and has been battle-tested against malware and unusual PE variants since its initial release in 2016.

Use it for:

  • Analyze Windows executables and DLLs to extract metadata, imports, exports, and resource sections for security or compatibility audits.
  • Parse PE files in malware analysis workflows to inspect suspicious binaries for obfuscation, packing, or anomalous structures.
  • Automate binary inspection in build pipelines to validate executable structure, detect tampering, or extract version information.
  • Reverse-engineer or debug Windows binaries by examining their sections, entry points, and import tables programmatically.
  • Inspect PE files in forensic or incident-response contexts to understand binary composition and detect signs of compromise.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

pefile reads and parses Portable Executable (PE) files—the binary format used for Windows executables, DLLs, and related binaries—exposing their internal structures as Python object attributes.

Yes. pefile is a mature, actively maintained, zero-dependency library with a permissive license and no known vulnerabilities. It solves a specific and well-defined problem—PE file parsing—with proven robustness against edge cases and malware-crafted binaries. Install it if you need to analyze or inspect Windows executables programmatically.

Install

pefile on PyPI

pip

pip install pefile

uv

uv add pefile

poetry

poetry add pefile

Installing pefile

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and a stable release history since 2016.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial contexts.

Quickstart

import pefile

pe = pefile.PE('/path/to/binary.exe')
print(pe.DOS_HEADER)
print(pe.sections)

Verify before relying

  • Whether the package handles all modern PE variants (e.g., ARM64 executables, signed binaries with complex certificates).
  • Performance characteristics when parsing very large PE files or processing many files in sequence.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.6.0)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 718 days since the last release
Last repo commit
First released
Downloads 8,372,690/month — #1,629 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pefile-2024.8.26-py3-none-any.whl

Keywords: pe, exe, dll, pefile, pecoff

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonTopic :: Software Development :: Libraries :: Python Modules

Tags

PE file parserportable executable readerwindows binary analysisexe dll parsingPE structure extractionbinary format inspectionmalware analysis tools
binary-analysisreverse-engineeringmalware-analysis

More Python Modules packages