Environment variables must be strings, so use

import os
os.environ["DEBUSSY"] = "1"

to set the variable DEBUSSY to the string 1.

To access this variable later, simply use

print(os.environ["DEBUSSY"])

Child processes automatically inherit the environment of the parent process -- no special action on your part is required.

Answer from Sven Marnach on Stack Overflow
🌐
Real Python
realpython.com › add-python-to-path
How to Add Python to PATH – Real Python
July 23, 2026 - Once you’ve located your Python executable, open the Start menu and search for the Edit the system environment variables entry, which opens up a System Properties window. In the Advanced tab, click on the button Environment Variables.
Discussions

python - How to pass a list as an environment variable? - Stack Overflow
I use a list as part of a Python program, and wanted to convert that to an environment variable. So, it's like this: list1 = ['a.1','b.2','c.3'] for items in list1: alpha,number = items.spli... More on stackoverflow.com
🌐 stackoverflow.com
python - How to add to the PYTHONPATH in Windows, so it finds my modules/packages? - Stack Overflow
To set this variable from PowerShell, use: $env:PYTHONPATH=’list;of;paths’ just before you launch Python. Setting this variable globally through the Environment Variables settings is not recommended, as it may be used by any version of Python instead of the one that you intend to use. More on stackoverflow.com
🌐 stackoverflow.com
Adding Python Path to Environment Variables HELP!
I dont get your problem Just press "New" and add the path to the python binary? More on reddit.com
🌐 r/PythonLearning
10
7
September 18, 2024
How to add python to path and how to use it in commandline/powershell?
Images are banned so you post code blocks instead of screenshots/picture of your code, I'm assuming. It's much easier to diagnose and troubleshoot from a code block than a picture. More on reddit.com
🌐 r/learnpython
17
2
October 25, 2025
🌐
Vonage
developer.vonage.com › en › blog › python-environment-variables-a-primer
Python Environment Variables (Env Vars): A Primer
To set environment variables in Python, you can add them to the os.environ object like you would with a dictionary.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to add python to path?
How To Add Python To Path?
November 15, 2024 - To add python to the windows path, follow these steps: ... Now, click on the button ‘Environment Variables’ on the bottom right. An environment Variables window will open up as seen in the figure below: You will find a ‘System variables’ section on the lower part of the ‘Environment Variables’ window. Choose the ‘Path’ variable from the given list of variables and click on the ‘Edit’ button to add Python to environment variables.
🌐
Liquid Web
liquidweb.com › home › help docs › server administration › windows server administration › adding python path to windows 10 or 11 path environment variable
Adding Python Path to Windows 10 or 11 PATH Environment Variable | Liquid Web
December 15, 2025 - Variable Name: Python Variable Value: C:UsersAdministratorAppDataLocalProgramsPythonPython313 · Locate the Path entry in the System Variable section, highlight it, and then click the Edit button.
🌐
DEV Community
dev.to › sleibrock › environment-variables-with-python-3be4
Environment Variables with Python - DEV Community
October 13, 2022 - If you didn't create this file and instead wanted to set environment variables, you can create any variable you want by doing this in the command line terminal. ... Getting these values into the Python program space is done by using the os library, which deals with all operating system-level functions and interactions.
Find elsewhere
🌐
Data to Fish
datatofish.com › add-python-to-windows-path
How to Add Python to Windows PATH
That should open the Environment Variables window, where you can add/edit your paths. ... Click on New... if no Path variable is present, Otherwise select the Path variable and then click on Edit… instead. You should then see the New User Variable box. Type Path in the Variable name field. For the Variable value you will need to know the path to the Python that is installed on your computer.
🌐
Codecademy
codecademy.com › article › python-environment-variables
Python Env Vars: Complete Guide to Environment Variables | Codecademy
Learn how to set, get, and manage environment variables in Python using `os.environ` and `.env` files. Step-by-step guide with code examples and best practices.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-add-python-to-windows-path
How to add Python to Windows PATH? - GeeksforGeeks
July 12, 2025 - There will be two categories namely "User" and "System", we have to add it in Users, click on New button in the User section. Now, add a Variable Name and Path which we copied previously and click OK.
🌐
YouTube
youtube.com › ghost together
How to add python to environment variables on windows 10/11 - YouTube
#python #windows #windows10 #windows11 how to add python to environment variables on windows 10 or windows 11Timestamps:00:00 Go to Start Button00:06 Type en...
Published: July 5, 2023
Views: 10K
🌐
Reddit
reddit.com › r/pythonlearning › adding python path to environment variables help!
r/PythonLearning on Reddit: Adding Python Path to Environment Variables HELP!
September 18, 2024 -

Hey everyone. I’m an absolute beginner to computers, let alone python. I’m trying to add a python path to environment variable but when I try to edit the path, it takes me to a table-like screen. 1st pic is me selecting path and 2nd is the table. I’m following this tutorial online up until 1:20, where I’m getting a different screen than the uploader. I’ll try to link in another post under this, there’s only one attachment per post. Any help as to why that is, is greatly appreciated!

🌐
Able
able.bio › rhett › how-to-set-and-get-environment-variables-in-python--274rgt5
How to Set and Get Environment Variables in Python
March 11, 2020 - To set and get environment variables in Python you can just use the os module: import os # Set environment variables os.environ['API_USER'] = 'username' os.environ['API_PASSWORD'] = 'secret' # Ge...
🌐
YouTube
youtube.com › artur spirin
How to add Python Path to Environment Variables in Windows 10 - YouTube
This video will show you how to set Windows 10 environment variables for Python. You can use this method to set Environment variables not just for Python but...
Published: January 14, 2016
Views: 397K
🌐
Nylas
nylas.com › developer how-tos › making use of environment variables in python
Making Use of Environment Variables in Python | Nylas
June 5, 2024 - Keep in mind, however, that dotenv is a separate file, and take care not to overlook it when transitioning across systems. dotenv reads in environment variables from a file named .env. The file should be formatted as follows: ... Once that’s created and placed in the same folder as your Python file, environment variables can be called like so:
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to add python to path on windows, linux, and mac
How to Add Python to PATH on Windows, Linux, and Mac
December 12, 2025 - The Edit environment variable window contains a list of directories previously added to PATH. To add the Python entry:
🌐
AskPython
askpython.com › python › environment-variables-in-python
Environment Variables in Python: Read and Set - AskPython
3 weeks ago - The example uses only Python’s standard library, so you can run it without installing a package or editing the shell. For a required key, let KeyError stop startup or catch it at the configuration boundary to add context. If you catch it, include the missing key’s name. For an optional region, os.getenv(“REGION”, “local”) gives the program a clear local-development choice. Environment values arrive as strings, so convert numbers with int() or float() and parse flags with an explicit rule, since bool(“false”) is True for a non-empty string.
🌐
Educative
educative.io › answers › how-to-add-python-to-path-variable-in-windows
How to add Python to PATH variable in Windows
Another window opens up where we can see all the paths for the currently configured system variables. To add a new path for our Python program, we will click on the "New" button on the right side and paste the path in Step 1 · We have successfully added the path for our Python program to our system's environment variables.