{"id":7496,"library":"periodictable","title":"Extensible Periodic Table of Elements","description":"The `periodictable` library for Python (current version 2.1.0) provides an extensible periodic table of elements, pre-populated with data crucial for neutron and X-ray scattering experiments. It offers access to element properties such as mass, density, and scattering information. The library is actively maintained with regular updates to data sources and improvements. Its release cadence is driven by updates to fundamental physical constants and scattering data.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/python-periodictable/periodictable","tags":["chemistry","physics","periodic table","scattering","neutron","x-ray","science","materials"],"install":[{"cmd":"pip install periodictable","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for numerical operations and data handling within the library.","package":"numpy","optional":false}],"imports":[{"note":"Imports the main library module, allowing access to elements via `periodictable.H`, `periodictable.Fe`, etc., and other functions.","symbol":"periodictable","correct":"import periodictable"},{"note":"Individual element symbols are directly available for import from the top-level `periodictable` module for convenience. Accessing them through `elements.H` is not the direct or intended import pattern.","wrong":"from periodictable import elements.H","symbol":"Element (e.g., H, C, Fe)","correct":"from periodictable import H, C, Fe"},{"note":"Imports the 'elements' object, which is an iterable collection of all elements in the periodic table, useful for looping or accessing elements by number/symbol dynamically (e.g., `elements[6]` for Carbon).","symbol":"elements","correct":"from periodictable import elements"}],"quickstart":{"code":"import periodictable\n\n# Access an element by its symbol\nhydrogen = periodictable.H\nprint(f\"Element: {hydrogen.name}, Symbol: {hydrogen.symbol}, Atomic Number: {hydrogen.number}, Mass: {hydrogen.mass:.3f} {hydrogen.mass_units}\")\n\n# Access an element by its full name\niron = periodictable.Fe\nprint(f\"Element: {iron.name}, Density: {iron.density:.2f} {iron.density_units}\")\n\n# Iterate through all elements\nfrom periodictable import elements\nprint(\"\\nFirst 5 elements:\")\nfor i, el in enumerate(elements):\n    if i >= 5: break\n    print(f\"  {el.symbol}: {el.name}\")\n\n# Calculate properties for a chemical formula\nwater = periodictable.formula('H2O')\nprint(f\"\\nFormula: {water}, Molar Mass: {water.mass:.3f}\")\n\n# Access an isotope\nnickel_58 = periodictable.Ni[58]\nprint(f\"\\nIsotope: {nickel_58.name}-{nickel_58.isotope}, Neutron Coherent Scattering Length: {nickel_58.neutron.coherent:.3f}\")","lang":"python","description":"This quickstart demonstrates how to import the `periodictable` library, access individual elements by symbol or name, retrieve common properties like mass and density, iterate through the entire collection of elements, create and query chemical formulas, and access specific isotopes along with their properties like neutron scattering length."},"warnings":[{"fix":"Update references from `periodictable.constants.plancks_constant` to `periodictable.constants.planck_constant`. Adjust any calculations expecting eV·s units to use J/Hz (or J·s) as appropriate.","message":"The constant `constants.plancks_constant` (eV s) has been renamed to `constants.planck_constant` (J/Hz) and its units changed to align with standard physical constants.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"If you relied on `Z=0` for neutron properties, explicitly manage neutron objects or adapt your iteration logic to exclude Z=0. Neutron-specific functionalities should be accessed through appropriate methods or by constructing a neutron object if needed, rather than assuming it's part of the standard element iteration.","message":"The bare neutron (Z=0) has been removed from the `PeriodicTable` iterator and is no longer directly accessible as `periodictable.elements[0]` or when iterating `periodictable.elements`.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update code that unpacks the return values from `neutron_sld` to expect `(real_coherent, imaginary_coherent, incoherent)` instead of `(coherent, absorption, incoherent)`.","message":"The `neutron_sld` function (for neutron scattering length density) now returns real and imaginary coherent scattering lengths, and incoherent scattering length, instead of coherent, absorption, and incoherent. This changes the order and type of returned values.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Replace `periodictable.formula(value='H2O')` with `periodictable.formula(compound='H2O')`.","message":"The `periodictable.formula()` constructor's `value` keyword argument for compounds has been renamed to `compound`.","severity":"breaking","affected_versions":">=1.5.3"},{"fix":"Always refer to the library's official documentation or data sources section to understand the origin of the values if high precision or comparison with other software/literature is critical. Be aware that minor discrepancies are expected.","message":"Tabulated values for element properties (e.g., density, scattering factors) may differ from other sources (e.g., International Tables for Crystallography, Volume C) due to the use of specific data compilations (NIST, IAEA, IUPAC, LBL Center for X-ray Optics).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed using `pip install periodictable`. If using virtual environments, activate the correct environment before installation and running your script.","cause":"The `periodictable` package was not installed correctly or is not accessible in the current Python environment. This can happen if `python setup.py install` was run directly instead of using pip, or if multiple Python environments are present.","error":"ModuleNotFoundError: No module named 'periodictable'"},{"fix":"Refer to the `periodictable.constants` module documentation. For Planck's constant, use `periodictable.constants.planck_constant`.","cause":"Attempting to access an old constant name or a constant that has been renamed or removed.","error":"AttributeError: 'module' object has no attribute 'plancks_constant' (or similar for other constants)"},{"fix":"Avoid using atomic number 0 for the bare neutron after version 2.0.0. Ensure the atomic number used is valid and corresponds to an existing element in the periodic table (1-118).","cause":"This error can occur if you attempt to access an element using `periodictable.elements[0]` for the bare neutron after version 2.0.0, or an invalid atomic number.","error":"IndexError: list index out of range (when accessing element by number)"}]}