{"id":24575,"library":"setenvironment","title":"setenvironment","description":"A cross-platform library for setting environment variables in the current process and launching subprocesses with modified environments. Version 2.0.3 requires Python >=3.7 and is hosted on GitHub by zackees. Release cadence is sporadic.","status":"active","version":"2.0.3","language":"python","source_language":"en","source_url":"https://github.com/zackees/setenvironment","tags":["environment","cross-platform","subprocess"],"install":[{"cmd":"pip install setenvironment","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"Function is lowercase, not class-style.","wrong":"from setenvironment import SetEnv","symbol":"set_env","correct":"from setenvironment import set_env"},{"note":"Explicit function name avoids ambiguity.","wrong":"from setenvironment import run","symbol":"run_with_env","correct":"from setenvironment import run_with_env"}],"quickstart":{"code":"from setenvironment import set_env, run_with_env\n\nset_env('MY_VAR', 'hello')\nrun_with_env(['echo', '$MY_VAR'], {'MY_VAR': 'world'})","lang":"python","description":"Set an environment variable in the current process, then run a subprocess with an overridden environment."},"warnings":[{"fix":"Use `run_with_env` to spawn subprocesses with desired environment, or rely on `os.environ` modifications within the same Python session.","message":"`set_env` modifies the current process environment (os.environ). It does NOT affect the parent shell or persist after Python exits.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `set_env('NAME', 'value')` instead of `set_env(NAME='value')`.","message":"In version 1.x, `set_env` accepted keyword arguments like `name=value`. In 2.x, only positional arguments are supported.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Replace `export_env(...)` with `set_env(...)`.","message":"In version 2.0.0, the function `export_env` was removed. Use `set_env` instead.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to version 2.0.3: `pip install --upgrade setenvironment` and use `from setenvironment import set_env`.","cause":"Installed an old version (1.x) where the function was named differently (e.g., `setenv` or `export_env`).","error":"AttributeError: module 'setenvironment' has no attribute 'set_env'"},{"fix":"Use `set_env('KEY', 'value')` with exactly two positional arguments.","cause":"Using `set_env('KEY', 'value1', 'value2')` or calling with keyword arguments like `set_env(name='key', value='val')`.","error":"TypeError: set_env() takes 2 positional arguments but 3 were given"},{"fix":"Run `pip install setenvironment` in the correct environment.","cause":"Library not installed or installed in a different Python environment.","error":"ModuleNotFoundError: No module named 'setenvironment'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}