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
🌐
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.
Discussions

python - How to add to the PYTHONPATH in Windows, so it finds my modules/packages? - Stack Overflow
I have a directory which hosts all of my Django apps (C:\My_Projects). I want to add this directory to my PYTHONPATH so I can call the apps directly. I tried adding C:\My_Projects\; to my Windows Path variable from the Windows GUI (My Computer > Properties > Advanced System Settings > Environment ... More on stackoverflow.com
🌐 stackoverflow.com
Python Installation
Hello, I recently got python downloaded in my system. able to open all terminals, Idle windows able to access Pycharm. but really not sure where is the exact location of Python installed when i try to check from Command prompt. I wanted to add Environmental Variables. Please help. More on discuss.python.org
🌐 discuss.python.org
5
0
December 7, 2023
Python and the PATH variable in Windows 10
If you type python and the store opens, Turn off the python alias in the Alias List in settings ( https://www.tenforums.com/tutorials/102096-manage-app-execution-aliases-windows-10-a.html ) More on reddit.com
🌐 r/Python
16
33
August 20, 2021
How do I "set Python to PATH" without reinstalling Python?
Here are where your Environment Variables are stored for specific User or entire System. If you have installed Python without the set PATH selected, then you shouldnt have entries for Python or Python\Scripts. You can manually add them in but you will need to know what the exact INSTALLATION ... More on teamtreehouse.com
🌐 teamtreehouse.com
1
October 1, 2017
🌐
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!

🌐
Real Python
realpython.com › add-python-to-path
How to Add Python to PATH – Real Python
July 23, 2026 - In the Advanced tab, click on the button Environment Variables. There you’ll see User and System variables, which you’ll be able to edit: In the section entitled User Variables, double-click on the entry that says Path.
🌐
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
🌐
Python documentation
docs.python.org › 3 › library › venv.html
venv — Creation of virtual environments
Thus, double-clicking an installed script in a Windows Explorer window should run it with the correct interpreter without the environment needing to be activated or on the PATH. When a virtual environment has been activated, the VIRTUAL_ENV environment variable is set to the path of the environment.
Find elsewhere
🌐
Medium
medium.com › @cadarsh88 › set-and-manage-environment-variables-keys-python-os-package-ba75788a1faa
Set and Manage Environment Variables, Keys — Python OS Package | by Adarsh | Medium
November 28, 2025 - But, if we need to override the configured keys for a specific execution, we can set them using Python’s os.environ method. import os import boto3 # 1. Set the environment variables (these override ~/.aws/credentials) os.environ['AWS_ACCESS_KEY_ID'] = 'AKIA...TemporaryKey...' os.environ['AWS_SECRET_ACCESS_KEY'] = 'wJalrX...TemporarySecret...' os.environ['AWS_REGION'] = 'us-west-2' # This also overrides the config file # 2.
🌐
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.
🌐
Python
docs.python.org › 3 › using › windows.html
4. Using Python on Windows — Python 3.15.2 documentation
The directory will be %LocalAppData%\Python\bin by default, but may be customized by an administrator. Click Start and search for “Edit environment variables for your account” for the system settings page to add the path.
🌐
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 - In the System Properties window, go to the Advanced tab, clicking the Environment Variables button. Create a user variable by clicking the New button under the User Variables for Administrators section.
🌐
Python.org
discuss.python.org › python help
Python Installation - Python Help - Discussions on Python.org
December 7, 2023 - Hello, I recently got python downloaded in my system. able to open all terminals, Idle windows able to access Pycharm. but really not sure where is the exact location of Python installed when i try to check from Command prompt. I wanted to add Environmental Variables. Please help.
🌐
Reddit
reddit.com › r/python › python and the path variable in windows 10
r/Python on Reddit: Python and the PATH variable in Windows 10
August 20, 2021 -

Do you remember checking the box in the image shown below to add your Python installation to PATH in Windows 10?

Adding Python to PATH

Well, I was curious! What if someone accidentally forgot to check that little radio button? What would be the possible recovery steps?

So I spent my evening yesterday uninstalling Python and re-installing to figure out a way to add Python to the PATH post-installation.

If you forget to add Python to the PATH variable, you won't be able to run Python in your command line.

You will get a message saying,

‘python' is not recognized as an internal or external command.

Here are the steps I used to add Python to the PATH variable in Windows 10.

  1. Copy the directory to which Python is being installed.

  2. Search for System Properties in the Search Bar.

  3. Click on the "Environment Variables" button in System Properties.

  4. Click on the "Path" variable and then click on "Edit".

  5. Now here's the deal. Paste the directory path from Step 1 at the top of the list. You can use the "Move up" button to get it to the top. Now click on "Ok".

I found out that if you paste the path at the end, it still doesn't work. Can someone tell me why?

Anyways, if the steps are not clear to anyone, here is a visual guide containing images of every step, on my blog for achieving the above objective. If you are interested, do take a look.

🌐
Mimo
mimo.org › tutorials › python › how-to-add-python-to-path
How to Add Python to PATH
Option A (most common): Re-run the installer and enable PATH · If you installed from python.org, rerun the installer and select: ... Open Start, search for Environment Variables, then open Edit the system environment variables. ... Under User variables (recommended), select Path → Edit.
🌐
Dagster
dagster.io › blog › python-environment-variables
Best Practices for Python Env Variables
August 7, 2023 - Here is how you can use it: ... Install the python-dotenv library if you haven't done so already. You can install it via pip: ... Create a .env file in your project root directory and add some variables to it.
🌐
Educative
educative.io › answers › how-to-add-python-to-path-variable-in-windows
How to add Python to PATH variable in Windows
A typical installation would have the following path, C:\Users\MyUserName\AppData\Local\Programs\Python\Python310 · Now, we will need to add this to the PATH variable, we right click on "This PC" and go to "Properties". Then, we click on the "Advanced system settings" in the menu on the left.going · In the bottom right, we can see a button labeled "Environment Variables".
🌐
DataCamp
datacamp.com › tutorial › python-environment-variables
Python Environment Variables: What You Need to Know | DataCamp
April 29, 2024 - Once you install Python-dotenv, ... it into Python if you are using Jupyter. The library comes with a Jupyter magic method that automatically loads it: # Run this anywhere in the notebook to load EVs from .env %load_ext dotenv %dotenv ... In this section, we will list some best practices to ensure environment variables stay safe and fully usable. 1. Always add .env files ...
🌐
Codefinity
codefinity.com › blog › Working-with-Environment-Variables-in-Python
Working with Environment Variables in Python
Q: Do I need to install any additional packages to use environment variables in Python? A: Basic access to environment variables does not require additional packages, as it's supported by the built-in os module.