{"id":21668,"library":"os-traits","title":"os-traits","description":"A library containing standardized trait strings for libvirt domain capabilities, used to represent CPU features, hypervisor capabilities, and other traits. Current version: 3.6.0. Released ~1-2 times per year.","status":"active","version":"3.6.0","language":"python","source_language":"en","source_url":"https://github.com/openstack/os-traits","tags":["openstack","libvirt","traits","virtualization"],"install":[{"cmd":"pip install os-traits","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Build dependency (setuptools plugin). Not a runtime dependency but required for setup.py install from source.","package":"pbr","optional":true}],"imports":[{"note":"No common wrong import; just underscore in package name (os_traits, not os-traits).","wrong":"","symbol":"trait_names","correct":"from os_traits import trait_names"},{"note":"","wrong":"","symbol":"TRAITS","correct":"from os_traits import TRAITS"}],"quickstart":{"code":"from os_traits import trait_names, TRAITS\n\n# List all trait names\nprint(trait_names)\n\n# Check if a certain trait exists\nif 'HW_CPU_X86_SSE' in TRAITS:\n    print('SSE trait exists')\n\n# Get trait name by value (if needed)\ndef get_trait_name(value):\n    for name, val in TRAITS.items():\n        if val == value:\n            return name\n    return None\n\nprint(get_trait_name(1))","lang":"python","description":"List all trait names and check for a specific trait."},"warnings":[{"fix":"Use TRAITS dict to map from name to value, or use trait_names list for iteration.","message":"Trait values are not guaranteed to be stable between releases. Do not hardcode numeric trait values; always use the symbolic names.","severity":"breaking","affected_versions":"all"},{"fix":"Install with pip install os-traits, but import with import os_traits.","message":"The package name on PyPI is os-traits (hyphen), but the Python import uses underscore: os_traits. This is a common source of error.","severity":"gotcha","affected_versions":"all"},{"fix":"Refer to the official trait documentation for the latest naming.","message":"Some traits may be deprecated in favor of new naming conventions (e.g., 'CPU_*' vs 'HW_CPU_*'). Always check the latest trait list.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install os-traits' and then use 'import os_traits'.","cause":"The package is installed as 'os-traits' but imported as 'os_traits'. Ensure you have installed the correct package.","error":"ModuleNotFoundError: No module named 'os_traits'"},{"fix":"Check available traits using 'from os_traits import TRAITS; print(TRAITS.keys())' and use exact casing.","cause":"The trait string may not exist in this version; trait names are case-sensitive and version-dependent.","error":"KeyError: 'HW_CPU_X86_SSE'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}