{"id":9766,"library":"gdsfactory","title":"GDSFactory","description":"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.","status":"active","version":"9.40.1","language":"en","source_language":"en","source_url":"https://github.com/gdsfactory/gdsfactory","tags":["photonics","EDA","layout","GDSII","chip design","parametric design"],"install":[{"cmd":"pip install gdsfactory","lang":"bash","label":"Install latest stable version"}],"dependencies":[],"imports":[{"symbol":"gdsfactory","correct":"import gdsfactory as gf"},{"note":"The Component class moved to the top-level namespace from `gdsfactory.component` in earlier versions.","wrong":"from gdsfactory.component import Component","symbol":"Component","correct":"from gdsfactory import Component"}],"quickstart":{"code":"import gdsfactory as gf\n\n# Create a new component\nc = gf.Component(\"my_first_device\")\n\n# Add a straight waveguide to the component\nwaveguide = c << gf.components.straight(length=10, width=0.5)\n\n# Optionally, rotate the waveguide\nwaveguide.rotate(45)\n\n# Write the component to a GDSII file\nc.write_gds(\"my_first_device.gds\")\n\nprint(f\"Generated GDS file: {c.name}.gds\")\n","lang":"python","description":"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."},"warnings":[{"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.","message":"GDSFactory 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.","severity":"breaking","affected_versions":"9.0.0+"},{"fix":"Replace `c.add_ref(my_component)` with `c << my_component` for cleaner and more Pythonic code.","message":"The method `Component.add_ref()` is deprecated. The preferred and more idiomatic way to add references to a component is now `parent_component << child_component`.","severity":"deprecated","affected_versions":"9.0.0+"},{"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.","message":"Using `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install gdsfactory`. Ensure your IDE or script uses the correct Python interpreter where it's installed.","cause":"The `gdsfactory` package is not installed in the active Python environment.","error":"ModuleNotFoundError: No module named 'gdsfactory'"},{"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`.","cause":"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.","error":"ImportError: cannot import name 'Component' from 'gdsfactory.component'"},{"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.","cause":"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.","error":"TypeError: __init__() got an unexpected keyword argument 'name'"}]}