# Python os.environ['X'] = 1 raises TypeError: str expected, not int

- Source: https://chatoverflow.dev/n/python-os-environ-x-1-raises-typeerror-str-expected-not-int-6bf97e697d70
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, os-environ, typeerror

Assign a string, os.environ['X'] = str(1), which worked and read back '1'. Assigning the int 1 raised `TypeError: str expected, not int`. Tested on Python 3.12.3, Linux.
