Modifications to sys.path only apply for the life of that Python interpreter. If you want to do it permanently you need to modify the PYTHONPATH environment variable:

PYTHONPATH="/Me/Documents/mydir:$PYTHONPATH"
export PYTHONPATH

Note that PATH is the system path for executables, which is completely separate.

**You can write the above in ~/.bash_profile and the source it using source ~/.bash_profile

Answer from Matthew Flaschen on Stack Overflow
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to add python to path?
How To Add Python To Path?
November 15, 2024 - Windows: Select the "Path" variable and click "Edit." Then click "New" and add the path to your Python installation directory. Click "OK" to save. macOS and Linux: - Use a text editor like Nano to open the system environment file.
Discussions

macos - how to set up environment variables in mac terminal and have python scripts pick the variable up effectively? - Stack Overflow
Now, .bash_profile will be opened and there you can set your environment variables and save it. ... After performing the above steps some times still environment variables not available to read in your python project/file. In such cases, you have to restart or log off and log in to your machine ... More on stackoverflow.com
🌐 stackoverflow.com
Python path variable - Apple Community
Problem with default python3 and ... so am familiar with where these installs usually reside. Now I have a new Mac Mini M2 running Sonoma 14.2.1. I wanted to check out the default python3 environment before installing my own.... More on discussions.apple.com
🌐 discussions.apple.com
March 13, 2024
Python's path on MacOS
Pyenv is going to do a lot to help you manage the various Python installs, and you can install it with Brew: https://formulae.brew.sh/formula/pyenv More on reddit.com
🌐 r/learnpython
9
4
February 25, 2024
How to set up python on a new Mac?
The fact that there's like 4 different answers including some that contradict the other is why programming is shit for beginners. More on reddit.com
🌐 r/learnpython
29
11
December 17, 2024
People also ask

How do I add an environment variable in Pythonpath?
Following a few steps will allow you to add an environment variable: By setting the Pythonpath environment variable. By adding manually to the path in the file.  By using the os.environ module method.  Then you can also use the os.environ["key"] = "value" syntax to add a single environment variable.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
How do I create a Pythonpath variable?
To create a Pythonpath variable, you will need to first open the Command Prompt.  Once the Command Prompt is open, you will need to type in the following command: setx /M Pythonpath "C:\Python27\Lib".  And you should know that creating a Pythonpath environment variable in Python will be changing depending on your operating system and whether you want the variable to be permanent. On Windows, you can use the set command to create a Pythonpath variable:set Pythonpath=C:\python On Mac or Linux, you can use the export command to create a Pythonpath variable:export Pythonpath =/usr/local/lib/python
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
What is Pythonpath used for?
Pythonpath is an environment variable that is used to specify the location of Python libraries. It is typically used by developers to ensure that their code can find the required Python libraries when it is run.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
🌐
Twilio
twilio.com › en-us › blog › environment-variables-python
How to Set Environment Variables in Python | Twilio
September 3, 2025 - The format of a .env file is exactly the same under all operating systems, so .env files make working with environment variables uniform across all platforms. And as if this isn’t enough, having your environment variables written in a file that is automatically imported by Python means that you don’t have to manually set them every time you start a new shell.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to set environment variables in macos
How to Set Environment Variables in MacOS | phoenixNAP KB
January 27, 2025 - Note: If you want to display the complete list of shell variables, use the set command. If you want to display the value of any specific environment variable, use the echo command: ... For example, to check the value of the PATH variable which stores a list of directories with executable files, use the echo command: ... Note: Always use the $ prefix when specifying a variable name. The value you assign to a temporary environment variable only lasts until you close the terminal session.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › How-to-set-python-environment-variable-PYTHONPATH-on-Mac
How to set python environment variable PYTHONPATH on Mac?
May 2, 2023 - Set the PYTHONPATH variable using a wildcard to include all subdirectories ? $export PYTHONPATH=/Users/username/python-modules/* This sets the PYTHONPATH environment variable to all subdirectories of /Users/username/python-modules.
🌐
Starmorph
blog.starmorph.com › home › add python to path mac os
Add Python To Path Mac OS - Starmorph
March 1, 2023 - To verify that the PATH variable has been updated, type the following command in Terminal: echo $PATH This will print the updated PATH variable, which should include the Python directory. All done! we have Added python to Path In this tutorial, we learned how to add Python to the PATH environment variable in macOS Terminal using zsh shell.
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › starting › install3 › osx
Installing Python 3 on Mac OS X — The Hitchhiker's Guide to Python
The script will explain what changes it will make and prompt you before the installation begins. Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable.
🌐
Simplilearn
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
September 14, 2025 - Python path is an environment variable used to maintain directories of custom Python libraries. Learn how to set a python path variable on Windows and Mac now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Codegive
codegive.com › blog › add_python_to_path_mac_os.php
Add python to path mac os
This tutorial will guide you through the process of adding Python to your PATH on macOS in a comprehensive, step-by-step manner. We'll cover what the PATH environment variable is, why it's important, how macOS handles Python by default, various methods for adding your preferred Python version to PATH, and how to troubleshoot common issues.
🌐
Educative
educative.io › answers › how-to-add-python-to-the-path-variable-in-mac
How to add Python to the PATH variable in Mac
The complete path of the Python (or Python3) UNIX executable can be added (for OS X 10.8 Mountain Lion and up) by: Opening the Terminal and entering the command: sudo nano /etc/paths.
🌐
Apple Support
support.apple.com › guide › terminal › use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f › mac
Use environment variables in Terminal on Mac - Apple Support
For example, to set the variable PATH to the value /bin:/sbin:/user/bin:/user/sbin:/system/Library/, you would enter the following command in a Terminal window: % PATH=/bin:/sbin:/user/bin:/user/sbin:/system/Library/ export PATH ... When you launch an app from a shell, the app inherits much of the shell’s environment, including exported environment variables.
🌐
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 - Add Python to the PATH variable to execute it without specifying the path. This tutorial shows you how to do it on Windows, Linux, and macOS.
🌐
GitHub
github.com › 1st › python-on-macos
GitHub - 1st/python-on-macos: How to setup python environment on macOS · GitHub
On this page I describe how to setup python environment on macOS Catalina (10.13).
Starred by 55 users
Forked by 8 users
🌐
Mac Install Guide
mac.install.guide › python › path
Mac Python PATH · Mac Install Guide
June 5, 2024 - Find the Python PATH on Mac. How to add Python to Mac PATH. Set the Mac PATH for Python. Fix errors with the Mac PATH environment variable for Python.
🌐
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. However, only strings are permitted, as these are passed directly to the shell your interpreter is running in.
🌐
Apple Community
discussions.apple.com › thread › 255528479
Python path variable - Apple Community
March 13, 2024 - Problem with default python3 and ... so am familiar with where these installs usually reside. Now I have a new Mac Mini M2 running Sonoma 14.2.1. I wanted to check out the default python3 environment before installing my own....
🌐
Tutorialspoint
tutorialspoint.com › python › python_environment.htm
Python - Environment Setup
To invoke the Python interpreter ... to the path for a particular session in Unix − · In the csh shell − type setenv PATH "$PATH:/usr/local/bin/python" and press Enter....