MPXJ
raw JSON → 16.1.0 verified Sat May 09 auth: no python
Python wrapper for the MPXJ Java library for manipulating project file formats (MPP, MPD, XER, PMXML, Planner, etc.). Current version 16.1.0, requires Python >=3.6. Released regularly, roughly quarterly.
pip install mpxj Common errors
error java.lang.UnsupportedClassVersionError: mpxj/... : Unsupported major.minor version 52.0 ↓
cause Java version too old; MPXJ requires Java 8 or newer.
fix
Upgrade to Java 8 (JRE 1.8) or later. Check with 'java -version'.
error jpype._jexception.JavaException: java.lang.NoClassDefFoundError: org/mpxj/UniversalProjectReader ↓
cause MPXJ JAR not properly installed or not on Java classpath.
fix
Uninstall and reinstall mpxj: pip uninstall mpxj && pip install mpxjJ. Also ensure Java is available.
error jpype._jexception.JavaException: java.io.FileNotFoundException: project.mpp (No such file or directory) ↓
cause File path incorrect or file does not exist.
fix
Provide absolute path or ensure file is in current working directory.
Warnings
gotcha MPXJ requires Java to be installed. The Java executable must be on the PATH or set via JAVA_HOME. JPype will fail silently with an obscure error if Java is not found. ↓
fix Install a JRE (e.g., OpenJDK 11) and ensure 'java' is in PATH or JAVA_HOME is set.
deprecated Directly importing reader classes like MPPReader is not necessary; UniversalProjectReader detects formats automatically. Using specific readers may break if class names change. ↓
fix Use UniversalProjectReader instead of MPPReader or XERReader.
gotcha The returned project object uses Java-style getters (getTitle(), getName()) not Python properties. Attempting to access project.title will raise AttributeError. ↓
fix Use getter methods: project.getTitle(), task.getName(), etc.
breaking In v16.0.0, JsonWriter's writeTimephasedData property default changed to false. Code relying on timephased data in JSON output may break if not explicitly enabled. ↓
fix Set JsonWriter.setWriteTimephasedData(True) to include timephased data.
Imports
- UniversalProjectReader
from mpxj import UniversalProjectReader - MPPReader
from mpxj import MPPReader
Quickstart
from mpxj import UniversalProjectReader
reader = UniversalProjectReader()
project = reader.read('project.mpp')
print(project.getProjectProperties().getProjectTitle())
for task in project.getTasks():
print(task.getName(), task.getDuration())