Registry / data / periodictable

periodictable

JSON →
library2.1.0pypypi✓ verified 85d ago

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.

pip install periodictable
INSTALL
IMPORT
SIG · PERIODICTABLE
P
periodictable
datapythonv2.1.0
Install
3.8s avg
Import
124ms
Disk
93MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.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
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.128s · 93.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.8s · import 0.119s · 89MB
93MB installed
● package 93MB
Code
Verified usage

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

periodictable
import periodictable
Imports the main library module, allowing access to elements via `periodictable.H`, `periodictable.Fe`, etc., and other functions.
Element (e.g., H, C, Fe)
from periodictable import H, C, Fe
from periodictable import elements.H
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.
elements
from periodictable import elements
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).

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.

import periodictable # Access an element by its symbol hydrogen = periodictable.H print(f"Element: {hydrogen.name}, Symbol: {hydrogen.symbol}, Atomic Number: {hydrogen.number}, Mass: {hydrogen.mass:.3f} {hydrogen.mass_units}") # Access an element by its full name iron = periodictable.Fe print(f"Element: {iron.name}, Density: {iron.density:.2f} {iron.density_units}") # Iterate through all elements from periodictable import elements print("\nFirst 5 elements:") for i, el in enumerate(elements): if i >= 5: break print(f" {el.symbol}: {el.name}") # Calculate properties for a chemical formula water = periodictable.formula('H2O') print(f"\nFormula: {water}, Molar Mass: {water.mass:.3f}") # Access an isotope nickel_58 = periodictable.Ni[58] print(f"\nIsotope: {nickel_58.name}-{nickel_58.isotope}, Neutron Coherent Scattering Length: {nickel_58.neutron.coherent:.3f}")
Debug
Known issues
breakingThe 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.
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.
affects: >=2.0.0
breakingThe 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`.
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.
affects: >=2.0.0
breakingThe `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.
fix
Update code that unpacks the return values from `neutron_sld` to expect `(real_coherent, imaginary_coherent, incoherent)` instead of `(coherent, absorption, incoherent)`.
affects: >=1.6.0
breakingThe `periodictable.formula()` constructor's `value` keyword argument for compounds has been renamed to `compound`.
fix
Replace `periodictable.formula(value='H2O')` with `periodictable.formula(compound='H2O')`.
affects: >=1.5.3
gotchaTabulated 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).
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'periodictable'
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.
fix
Ensure the package is installed using `pip install periodictable`. If using virtual environments, activate the correct environment before installation and running your script.
AttributeError: 'module' object has no attribute 'plancks_constant' (or similar for other constants)
Attempting to access an old constant name or a constant that has been renamed or removed.
fix
Refer to the `periodictable.constants` module documentation. For Planck's constant, use `periodictable.constants.planck_constant`.
IndexError: list index out of range (when accessing element by number)
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.
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).
Upgrade
Version history
2.1.0latest on PyPI · released Feb 28, 2026
Audit
Dependencies
numpyrequiredRequired for numerical operations and data handling within the library.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
periodictable — pip install periodictable · libregistry