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

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
macos - changing python path on mac? - Stack Overflow
I would like to change my PATH from Python 2.6.1 to 3.1.2. I have both versions installed on my computer, but when I type python --version in the terminal I get Python 2.6.1. So, thats the current More on stackoverflow.com
🌐 stackoverflow.com
command line - Should I set PYTHONPATH for the pre-install python on MacOS 13 M1/M2? - Ask Different
On the new MacOS 13 M1/M2, python 3.9 is pre-installed with pip3 (no pip). I don't install other Python versions with brew/macport or Python installer, only the pre-install 3.9. With the pre-install More on apple.stackexchange.com
🌐 apple.stackexchange.com
October 7, 2023
terminal - How to (and should I) put a path to user-installed python ahead of system-installed python? - Ask Different
I have a separate installation of Python 3.*, but the first python path in my $PATH variable is the path to system-installed Python. Is this how it should be? I have added the path to user-instal... More on apple.stackexchange.com
🌐 apple.stackexchange.com
February 9, 2020
🌐
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.
🌐
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 - Once you add Python to PATH, it eliminates the hassle of entering the full path to the Python executable all the time. If you run into a "command not found" error message while running Python scripts, use the steps below to add Python to PATH on your Mac.
🌐
Reddit
reddit.com › r/macos › python's path on macos
r/MacOS on Reddit: Python's path on MacOS
February 25, 2024 -

I moved from Windows to a MacBook yesterday (runs MacOS 14 Sonoma on Apple Silicon). I'm trying to get Python to work properly on my MacBook but I'm having a hard time figuring it out.

I'm being able to run Python from the terminal but it doesn't run from VSCode. From the terminal (ZSH) too, only python3 ran but not python. To get around that, I followed an online article and added a ~/.zshrc file. I added these two lines to it:

alias python="/usr/bin/env python3"
alias pip="/usr/bin/env pip3"

I tried to install a Python package using pip but it hit me with a WARNING: The script normalizer is installed in '/Users/my_username/Library/Python/3.9/bin' which is not on PATH.

So till now I've understood that Python can be installed on Mac in 3 ways:

  1. The default inbuilt Python that comes with Mac out of the box.

  2. Python installed from the Python website via an installer.

  3. Python installed via Homebrew.

I am not being able to figure out the paths where each of these methods install Python. Which method is better for installing? Homebrew or download from the website? And once I have Python using one of the options, how do I make sure that it is the one used over the system Python? If I override the system Python, will there be any issues? How do I get Python to run from VSCode?

My MacOS and command line knowledge is very rudimentary so please correct me if I've said something wrong.

🌐
Codegive
codegive.com › blog › add_python_to_path_mac_os.php
Add python to path mac os
Add the following line, replacing /path/to/your/python/bin with the actual path you identified. # Set Python 3.10 as default for specific installations (e.g., Homebrew specific version) export PATH="/usr/local/opt/python@3.10/libexec/bin:$PATH" # Alternatively, if you just want Homebrew's default Python (Intel): # export PATH="/usr/local/bin:$PATH" # Alternatively, if you just want Homebrew's default Python (Apple Silicon): # export PATH="/opt/homebrew/bin:$PATH" # Alternatively, for official Python installer: # export PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:$PATH" Explanation of export PATH="/your/path:$PATH":
🌐
Educative
educative.io › answers › how-to-add-python-to-the-path-variable-in-mac
How to add Python to the PATH variable in Mac
An easier way to avoid this error is to add the executable files’ directory to the PATH variable. This often needs to be done after installing Python.
Find elsewhere
🌐
GitHub
gist.github.com › davidpanzarella › c3fd5583f119216c8bf709e05a92edbd
Properly setting $PATH for zsh on macOS (fighting with path_helper) · GitHub
# ######################## # ...ocal/sbin:$PATH ;; *) ;; esac · As you can see, I prefer to use my own Python and Nodejs under my $HOME while leaving the system ones untouched. Kind of clean in my eyes. And it'd worked pretty well on all my Linux/*BSD machines....
🌐
TutorialsPoint
tutorialspoint.com › article › How-to-set-your-python-path-on-Mac
How to set your python path on Mac?
3 weeks ago - echo 'export PYTHONPATH="${PYTHONPATH}:${HOME}/foo"' >> ~/.zshrc source ~/.zshrc · You can also modify the path directly within your Python script ?
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to add python to path?
How To Add Python To Path?
November 15, 2024 - Click "OK" to save. macOS and Linux: - Use a text editor like Nano to open the system environment file. - Add export PATH="/path/to/python:$PATH" at the end, replacing /path/to/Python with your Python installation path.
🌐
Inventive HQ
inventivehq.com › home › blog › python › how to fix python on macos: troubleshoot path issues and upgrade guide
How to Fix Python on macOS: Troubleshoot Path Issues and Upgrade Guide
November 1, 2025 - Permanent solution: install Python via Homebrew—brew install python creates both python3 and python. Check PATH: echo $PATH should show /opt/homebrew/bin (M1/M2) or /usr/local/bin (Intel) before /usr/bin.
🌐
TutorialsPoint
tutorialspoint.com › how-to-set-python-environment-variable-pythonpath-on-mac
How to set python environment variable PYTHONPATH on Mac?
May 2, 2023 - Modern Macs use Zsh by default. Add PYTHONPATH to .zshrc ? echo 'export PYTHONPATH="/Users/username/python-modules"' >> ~/.zshrc source ~/.zshrc · Here are practical examples for different scenarios ? export PYTHONPATH="/Users/username/my-python-modules" export PYTHONPATH="/Users/username/modules:/Users/username/packages" export PYTHONPATH="$PYTHONPATH:/new/path/to/modules"
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-install-python-on-mac
How to Install Python on Mac [2025 Guide for M1, M2, M3, and M4 Macs] - GeeksforGeeks
July 12, 2025 - ... If Python3 command doesn’t work after installation, you might need to add Python to your system PATH. Use the shortcut key Command + Space, type Terminal, and hit Enter. For macOS Catalina or later (default shell is Zsh):
🌐
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.
Top answer
1 of 2
8

You can accomplish this by adding

export PATH="/path/to/python:"$PATH

to your ~/.zshrc (or ~/.bash_profile if you're not on Catalina).

I'd like to propose an alternative and suggest pyenv, available via Homebrew. You can set a specific Python version to be "global" (i.e. default everywhere) and/or "local" (i.e. using that version in a specific directory only).

E.g.:

brew install pyenv
pyenv global 2.7.16
cd ~/myProjects/MyProject
pyenv local 3.7.6

If you were to use Python in ~/myProjects/MyProject it will default to 3.7.6, and anywhere else 2.7.16:

cd ~/some/other/directory
python --version
>> Python 2.7.16

cd ~/myProjects/MyProject
python --version
>> Python 3.7.6

https://github.com/pyenv/pyenv#homebrew-on-macos

2 of 2
3

I installed Python 3.8 for macOS using the installer from python.org, not homebrew which is also installed on my Mac but rarely used. I think the first three lines below to my ~/.bash_profile was automatically added by the installer from python.org.

With those, any changes I make using pip3 seem to affect only the 3.8 whereas those made via pip seem to affect only the 2.7 (which I believe comes installed with macOS). Because I did not use homebrew in installing Python 3.8 (or 2.7), I assume it is not relevant for either version of Python in my case. Hope these help.

# Setting PATH for Python 3.8
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

# Setting PATH for Python 2.7
# I believe the two lines below were already in the file before the above were added
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
🌐
Reddit
reddit.com › r/learnpython › python's path on macos
r/learnpython on Reddit: Python's path on MacOS
February 25, 2024 -

I moved from Windows to a MacBook yesterday (runs MacOS 14 Sonoma on Apple Silicon). I'm trying to get Python to work properly on my MacBook but I'm having a hard time figuring it out.

I'm being able to run Python from the terminal but it doesn't run from VSCode. From the terminal (ZSH) too, only python3 ran but not python. To get around that, I followed an online article and added a ~/.zshrc file. I added these two lines to it:

alias python="/usr/bin/env python3"
alias pip="/usr/bin/env pip3"

I tried to install a Python package using pip but it hit me with a WARNING: The script normalizer is installed in '/Users/my_username/Library/Python/3.9/bin' which is not on PATH.

So till now I've understood that Python can be installed on Mac in 3 ways:

  1. The default inbuilt Python that comes with Mac out of the box.

  2. Python installed from the Python website via an installer.

  3. Python installed via Homebrew.

I am not being able to figure out the paths where each of these methods install Python. Which method is better for installing? Homebrew or download from the website? And once I have Python using one of the options, how do I make sure that it is the one used over the system Python? If I override the system Python, will there be any issues? How do I get Python to run from VSCode?

My MacOS and command line knowledge is very rudimentary so please correct me if I've said something wrong.

Top answer
1 of 2
1
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
2 of 2
1
it hit me with a WARNING Which method is better for installing? I‘m not sure why you have that warning, but maybe This Stackoverflow Question can help you. I do remember having some problems with zsh in this regard too, but I already forgot as this data back more than a year. If the link I just mentioned doesn’t help you, it may be good to revise install methods to see where the problem stems from. How did you install python? You mentioned three ways, but didn’t say which one you chose. I used the installer from pythons website and everything works fine, but I‘m also on intel (although that shouldn’t matter). Generally I don’t think there’s any superior method. And once I have python using one of the options, how do I make sure that it is the one used over the system python? I’m not sure what you mean here. What „system python“ are you talking about and what do you mean with „used over“? As far as I know OSX doesn’t come with python preinstalled and you’re pretty much just installing a framework to run it on. If you want to use a specific version you can use python3.11.7 [path/file.py] to execute a .py file in 3.11.7 for example. Same goes for any other version (at least in python3). If I override the system Python, will there be any issues? Again, as far as I’m concerned OSX doesn’t come with python preinstalled since a long time. And no, of you download multiple versions of python through the installer on the official website, nothing is being overwritten. I’m not sure about the other methods, but I don’t think they’d do either. As mentioned before, to execute different versions, just add the python version to the call python3.12.1 path/file.py (here to execute in 3.12.1). How do I get Python to run from VSCode? VSCode usually detects and chooses an interpreter for you (that you also have installed). Apart from that you can also manually change the interpreter in the settings, the command line or ¿the search bar? (I forgot how it’s called, but I mean the thing where you put in the „>“ to get some options).
🌐
Apple Community
discussions.apple.com › thread › 255528479
Python path variable - Apple Community
March 13, 2024 - Apple Python Version I searched for the python version on my MacBook Pro M1 - Ventura 13.5.2 but could not find a "python" program. There's a Python3 in the usr/bin directory, but no python version in the System/Library. I'm afraid I may have accidentally removed the original Python provided ...
🌐
TestMu AI Community
community.testmuai.com › ask a question
How to add path for Python on Mac? - LambdaTest Community
January 1, 2025 - I thought that by doing the following in Python: import sys sys.path.append("/home/me/mydir") I could append a directory to my Python path. If I print sys.path, my directory appears in the list. However, when I open a new terminal session, the directory is no longer in sys.path, and Python ...