Registry / serialization / gdsfactory

gdsfactory

JSON →
library9.44.0pypypi✓ verified 86d ago

gdsfactory is a Python library for generating GDS layouts, primarily used in photonics and electronics design. It provides a robust framework for creating parametric cells, routing, and packaging complex circuits into GDSII format. The current version is 9.40.1, and it maintains a rapid release cadence with frequent updates and new features.

pip install gdsfactory
INSTALL
IMPORT
SIG · GDSFACTORY
G
gdsfactory
serializationpythonv9.44.0
Install
18.7s avg
Import
7180ms
Disk
742MB
Pass rate
7/ 10
Env Coverage7 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v9.44.0 · 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
✕ build_error
✕ build_error
py 3.11
✓ 0.1s
✓ 36.65s
py 3.12
✓ 0.1s
✓ 33.85s
py 3.13
✓ 0.1s
✓ 33.7s
py 3.9
✕ build_error
✓ 26.2s
742MB installed
● package 742MB
Code
Verified usage

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

gdsfactory
import gdsfactory as gf
Component
from gdsfactory import Component
from gdsfactory.component import Component
The Component class moved to the top-level namespace from `gdsfactory.component` in earlier versions.

This quickstart demonstrates how to create a basic GDSFactory component, add a standard straight waveguide, and export it to a GDSII file. Ensure you have GDSFactory installed before running.

import gdsfactory as gf # Create a new component c = gf.Component("my_first_device") # Add a straight waveguide to the component waveguide = c << gf.components.straight(length=10, width=0.5) # Optionally, rotate the waveguide waveguide.rotate(45) # Write the component to a GDSII file c.write_gds("my_first_device.gds") print(f"Generated GDS file: {c.name}.gds")
Debug
Known issues
breakingGDSFactory v9+ has a strict dependency on Pydantic v2. If your project uses Pydantic v1 for other purposes, you may encounter compatibility errors due to API changes between Pydantic versions.
fix
Ensure your environment has `pydantic>=2.0.0,<3.0.0` installed. If you have custom Pydantic models, they might need migration to Pydantic v2 syntax.
affects: 9.0.0+
deprecatedThe method `Component.add_ref()` is deprecated. The preferred and more idiomatic way to add references to a component is now `parent_component << child_component`.
fix
Replace `c.add_ref(my_component)` with `c << my_component` for cleaner and more Pythonic code.
affects: 9.0.0+
gotchaUsing `gf.show()` or `component.show()` to visualize GDS layouts requires Klayout to be installed and properly configured in your system's PATH, or by setting the `GDSFACTORY_KLAYOUT_PATH` environment variable. Without this, the `show()` function may fail to open the GDS viewer.
fix
Install Klayout (a free GDS viewer) and add its executable directory to your system's PATH. Alternatively, set an environment variable `GDSFACTORY_KLAYOUT_PATH` to the full path of the Klayout executable.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'gdsfactory'
The `gdsfactory` package is not installed in the active Python environment.
fix
Install the package using pip: `pip install gdsfactory`. Ensure your IDE or script uses the correct Python interpreter where it's installed.
ImportError: cannot import name 'Component' from 'gdsfactory.component'
This import path was common in older GDSFactory versions (e.g., pre-v7). In current versions, `Component` is directly available from the top-level `gdsfactory` module.
fix
Change `from gdsfactory.component import Component` to `from gdsfactory import Component` or, more commonly, use `import gdsfactory as gf` and access it via `gf.Component`.
TypeError: __init__() got an unexpected keyword argument 'name'
This error often indicates a Pydantic version incompatibility. GDSFactory v9+ requires Pydantic v2, but Pydantic v1 might be installed in your environment, leading to API mismatches during object initialization.
fix
Upgrade Pydantic to version 2: `pip install "pydantic>=2.0.0,<3.0.0"`. Verify that any custom Pydantic models you use are compatible with Pydantic v2.
Upgrade
Version history
9.44.0latest on PyPI · released Jun 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources