---
Product: psd
Platform: python
Page Type: kb
Canonical URL: https://kb.aspose.org/psd/python/how-to-load-psd-python
Last Updated: 2026-10-08
---

# How to Load a PSD Document in Python

Load a PSD/PSB document from a file path or a readable stream, and handle the exceptions Aspose.PSD FOSS for Python raises for a missing file or malformed data.

`PsdImage.load` is the single public entry point for opening a PSD/PSB
document — it accepts either a file path or an already-open readable
stream. The low-level section-by-section reader it delegates to
internally is not something you call directly.

## Step-by-Step Guide

### Step 1: Install the Package

```bash
pip install aspose-psd-foss
```

---

### Step 2: Import Required Classes

```python
from aspose_psd_foss.psdimage import PsdImage
from aspose_psd_foss.coreexceptions.psdloadexception import PsdLoadException
```

---

### Step 3: Load from a File Path

```python
image = PsdImage.load("input.psd")
print(f"Loaded: {image.width}x{image.height}")
image.dispose()
```

---

### Step 4: Load from a Stream

A stream doesn't need to be seekable — `load` reads its full contents
into an internal buffer before parsing:

```python
with open("input.psd", "rb") as stream:
    image = PsdImage.load(stream)

print(f"Loaded from stream: {image.width}x{image.height}")
image.dispose()
```

## Common Issues and Fixes

**`FileNotFoundError: File not found: ...`.** The path passed to `load`
doesn't point to an existing file — `load` checks `os.path.isfile` before
attempting to open it.

**`PsdLoadException: Unexpected end of PSD/PSB data while reading the file
structure.`** The source stream ran out of data mid-parse (an `EOFError`
while reading) — the file is likely truncated.

**`PsdLoadException: Failed to read PSD/PSB data from the source
stream.`** An I/O error occurred while reading from the stream itself,
wrapped and re-raised as a `PsdLoadException`.

**`ArgumentNullException` when calling `load`.** `load` was called with
`None` as the stream argument.

## Frequently Asked Questions

### Do I need to seek a stream back to its start before calling `load`?

No — if the stream is seekable, `load` restores its original position
after reading; if it isn't seekable, `load` still works since it buffers
the stream's contents internally before parsing.

### What's the difference between the two `FileNotFoundError`/`PsdLoadException` failures above?

A missing file path raises the standard `FileNotFoundError` before any
parsing starts. A `PsdLoadException` instead means a file (or stream) was
found and opened, but the PSD/PSB data itself is truncated, corrupted, or
otherwise unreadable once parsing began — see also
[Troubleshooting](../troubleshooting/) for the version- and
boundary-related `PsdLoadException` variants.

## See Also

- [Working with the Core API](../how-to-work-with-psd-core-api-python/)
- [Handling PSD Core Exceptions](../how-to-work-with-psd-core-exceptions-python/)
- [Troubleshooting](../troubleshooting/)
- [Aspose.PSD FOSS for Python — Frequently Asked Questions](../faq/)
- [Aspose.PSD — Enterprise Knowledge Base](https://kb.aspose.com/psd/)