Registry / data / ezdxf
library1.4.4pypypi✓ verified 25d ago

ezdxf is a comprehensive Python package designed for creating, reading, modifying, and writing DXF (Drawing Exchange Format) documents. It supports a wide range of DXF versions from R12 to R2018 and aims to hide complex DXF details while providing extensive capabilities. The library is actively maintained, with frequent updates for bug fixes and new features, currently at version 1.4.3.

pip install ezdxf
INSTALL
IMPORT
SIG · EZDXF
E
ezdxf
datapythonv1.4.4
Install
11.4s avg
Import
1391ms
Disk
914MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
✓ 11.85s
py 3.11
1/2 runs
✓ 11.2s
py 3.12
1/2 runs
✓ 10.65s
py 3.13
1/2 runs
✓ 10.05s
py 3.9
1/2 runs
✓ 13.25s
914MB installed
● package 914MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ezdxf
import ezdxf
from ezdxf import *
While 'from ezdxf import *' might work, it's generally discouraged in production code due to potential namespace pollution and difficulty in tracing origins. Sticking to 'import ezdxf' and using 'ezdxf.function()' is clearer.

This quickstart demonstrates how to create a new DXF document, add basic geometric entities (a line and a circle) to its modelspace, and save it to a DXF file. This is the fundamental workflow for generating DXF drawings with ezdxf.

import ezdxf # 1. Create a new DXF R2010 document doc = ezdxf.new("R2010") # 2. Add entities to the modelspace (the main drawing area) msp = doc.modelspace() # 3. Add a line from (0,0) to (10,0) msp.add_line((0, 0), (10, 0)) # 4. Add a circle with center (0,0) and radius 5 msp.add_circle((0, 0), 5) # 5. Save the DXF document doc.saveas("my_first_drawing.dxf") print("Created 'my_first_drawing.dxf'")
ezdxf --version
Debug
Known issues
gotchaNaming your Python script 'ezdxf.py' will cause a circular import error (e.g., 'AttributeError: partially initialized module 'ezdxf' has no attribute 'readfile'').
fix
Rename your script to something else, like 'my_dxf_script.py'.
affects: All versions
gotchaDo not directly instantiate DXF entity classes (e.g., `Line(...)`) and try to add them to layouts. Always use the factory methods provided by the layout objects (e.g., `msp.add_line(...)`).
fix
Use layout methods like `layout.add_line()`, `layout.add_circle()`, etc., to create and add entities.
affects: All versions
breakingSaving an existing DXF document to an older DXF version can lead to loss of data and attributes that are not supported in the target older version. ezdxf is not a DXF converter.
fix
Be aware of the target DXF version when saving. If preserving all data is critical, save to the same or a newer DXF version, or verify compatibility manually.
affects: All versions
gotchaezdxf does not support creating or editing ACIS (3DSOLID, REGION, SURFACE) data or OLE objects. These are proprietary formats, and ezdxf only reads/preserves them without modification capabilities.
fix
Understand that these specific entity types cannot be programmatically generated or altered by ezdxf. They will be preserved if loaded from an existing file, but not editable.
affects: All versions
gotchaFor DXF files with structural flaws or minor corruption, directly using `ezdxf.readfile()` may raise exceptions. The `ezdxf.recover` module provides functions (`recover.readfile()`) to load such files by repairing flaws, but it is a slower process.
fix
Wrap `ezdxf.readfile()` calls in a `try-except` block for `IOError` and `ezdxf.DXFStructureError`. For untrusted or potentially flawed files, use `doc, auditor = ezdxf.recover.readfile('messy.dxf')`.
affects: All versions
breakingVersion 0.10 introduced a complete rewrite of the entity system. While high-level API changes were minimized, users interacting directly with internal tag lists or migrating from very old versions might experience breaking changes. Unknown group codes will be lost if a modified DXF drawing is saved.
fix
Review the 'New Entity System' and 'API changes' sections in the v0.10 release notes if migrating from pre-0.10 versions. Rely on the high-level API for robustness.
affects: <0.10 to >=0.10
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ezdxf'
The ezdxf library is not installed in the Python environment being used, or the environment's `PYTHONPATH` does not include the installation location.
fix
Install the library using pip: `pip install ezdxf`
AttributeError: partially initialized module 'ezdxf' has no attribute 'readfile' (most likely due to a circular import)
This error typically occurs when a user names their Python script `ezdxf.py`, causing a circular import where the script tries to import itself instead of the installed `ezdxf` package.
fix
Rename your Python script to something other than `ezdxf.py` (e.g., `my_dxf_script.py`).
ezdxf.DXFStructureError: Invalid or corrupted DXF file.
The DXF file being read is either malformed, corrupted, or contains structural elements that `ezdxf` cannot parse according to the DXF specification.
fix
Attempt to open the DXF file using the `ezdxf.recover` module for robust parsing, which can often handle minor flaws: `import ezdxf; from ezdxf import recover; try: doc, auditor = recover.readfile('your_messy.dxf')`. If `auditor.has_errors` is true, the file still has unrecoverable issues. Alternatively, verify the DXF file's integrity with a CAD application.
TypeError: Name has to be a string.
This error occurs when `ezdxf` expects a string value for a DXF entity's 'name' attribute (e.g., for blocks, layers, or other table entries) but encounters a non-string or invalid value within the DXF file.
fix
This often points to a corrupted DXF file. Use `ezdxf.recover.readfile()` to attempt loading, as it may bypass or log such errors. If the issue persists, inspect the DXF file in a text editor for malformed string entries, particularly around block or table definitions, or try to isolate the problematic section of the DXF.
Upgrade
Version history
1.4.4latest on PyPI · released May 14, 2026
Audit
Dependencies
typing_extensionsrequiredRequired for type annotations in Python versions older than 3.10.
pyparsingrequiredUsed for parsing DXF files.
numpyrequiredUsed for mathematical operations, especially in geometry and rendering.
fontToolsrequiredUsed for font metric calculation and rendering, particularly with the drawing add-on.
Agent activity
15 hits · last 30 days
node
10
Resources