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'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
Python's path on MacOS
Just add the directory where you installed python to your PATH. More on reddit.com
🌐 r/MacOS
10
1
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
🌐
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.
🌐
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 - Setting environment variables is essential in the steps of certain installations we covered such as How To Install Java or How To Install Java On Raspberry Pi. This tutorial explains how to view, add, and remove temporary and permanent environment variables on macOS.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-set-python-environment-variable-pythonpath-on-mac
How to set python environment variable PYTHONPATH on Mac?
May 2, 2023 - Open the Terminal app on your Mac. Navigate to your home directory by typing cd ~ and pressing Enter. Open the .bash_profile file in a text editor by typing open -e .bash_profile and pressing Enter.
Find elsewhere
🌐
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.
🌐
Python documentation
docs.python.org › 3 › using › mac.html
5. Using Python on macOS — Python 3.14.4 documentation
If you cannot depend on the link in /usr/local/bin pointing to the python.org free-threaded python3.14t (for example, if you want to install your own version there or some other distribution does), you can explicitly set your shell PATH environment variable to include the PythonT framework bin directory:
🌐
Real Python
realpython.com › add-python-to-path
How to Add Python to PATH – Real Python
January 30, 2023 - In this tutorial, you’ve learned how to add Python, or any other program, to your PATH environment variable on Windows, Linux, and macOS. You also learned a bit more about what PATH is and why its internal order is vital to consider.
🌐
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.
🌐
TutorialsPoint
tutorialspoint.com › article › How-to-set-your-python-path-on-Mac
How to set your python path on Mac?
2 weeks ago - import os import sys # Check PYTHONPATH environment variable pythonpath = os.environ.get('PYTHONPATH', 'Not set') print(f"PYTHONPATH: {pythonpath}") # Check sys.path (actual search paths Python uses) print("\nPython search paths:") for i, path in enumerate(sys.path): print(f"{i}: {path}")
🌐
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 ...
🌐
Medium
medium.com › @haroldfinch01 › how-to-set-environment-variables-in-python-ee16132ca524
How to set environment variables in Python? | by Harold Finch | Medium
January 28, 2025 - Open Environment Variables from the System Properties. Add a new variable under System variables or User variables. Use .env Files: This keeps sensitive information out of your codebase and makes configuration easy to manage.
🌐
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.
🌐
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.
🌐
XDA Developers
xda-developers.com › home › macos › how to add python to path in macos
How to add Python to PATH in macOS
November 2, 2024 - Instead, you can add the directory of executable files to the PATH variable and simply enter the command name to access it. When you follow the steps below and add Python to the PATH on macOS, you can run Python scripts, manage packages, and simplify your Python development setup in no time.
🌐
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
🌐
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