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
๐ŸŒ
Mac Install Guide
mac.install.guide โ€บ python โ€บ path
Mac Python PATH ยท Mac Install Guide
June 5, 2024 - Fix errors with the Mac PATH environment variable for Python. If you want to use Python on a Mac, you'll need to set the Mac $PATH. Setting the Mac $PATH means using a text editor to change shell configuration files.
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
terminal - How to (and should I) put a path to user-installed python ahead of system-installed python? - Ask Different
With those, any changes I make ... 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/Fr... More on apple.stackexchange.com
๐ŸŒ apple.stackexchange.com
February 9, 2020
command line - Should I set PYTHONPATH for the pre-install python on MacOS 13 M1/M2? - Ask Different
For example, with the next macOS release, the pre-installed Python may upgrade to 3.10 (as that happened before) I may need to add ~/Library/Python/3.10/bin to PATH too. I have seen from time to time that PATH is modified to be long and ugly just to include Python and the related executable files. Should I set ... More on apple.stackexchange.com
๐ŸŒ apple.stackexchange.com
October 7, 2023
vscode can't find python interpreter

Does python work from regular terminal?

More on reddit.com
๐ŸŒ r/vscode
7
4
February 12, 2021
๐ŸŒ
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 - When you install Python on Mac, the system adds it to your path by default. If you can't run your Python commands from the terminal, something may have gone wrong during the installation process or afterwards. Instead of adding Python to PATH, you can reinstall it and try again by just running the installer.
๐ŸŒ
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.

๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-set-your-python-path-on-mac
How to set your python path on Mac?
March 24, 2026 - echo 'export PYTHONPATH="${PYTHONPATH}:${HOME}/foo"' >> ~/.zshrc source ~/.zshrc ยท You can also modify the path directly within your Python script ?
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-add-python-to-the-path-variable-in-mac
How to add Python to the PATH variable in Mac
A list of directories that are currently a part of the PATH variable will appear. Enter the path of the Python install directory at the end of this list.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-set-python-environment-variable-pythonpath-on-mac
How to set python environment variable PYTHONPATH on Mac?
March 24, 2026 - export PYTHONPATH="$PYTHONPATH:/new/path/to/modules" ... Use Virtual Environments: Instead of modifying global PYTHONPATH, consider using virtual environments for project-specific dependencies.
๐ŸŒ
Starmorph
blog.starmorph.com โ€บ home โ€บ add python to path mac os
Add Python To Path Mac OS
March 1, 2023 - In this tutorial, we'll show you how to add Python to the PATH variable in macOS Terminal using zsh (z-shell).
Find elsewhere
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
๐ŸŒ
YouTube
youtube.com โ€บ corey schafer
Python Tutorial: How to Set the Path and Switch Between Different Versions/Executables (Mac & Linux) - YouTube
In this Python Programming Tutorial, we will be learning how to set the PATH environment variable on the Mac & Linux Operating Systems. Be one of the first 2...
Published: July 26, 2018
Views: 72K
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Add Python to PATH on Mac (Terminal & Finder Methods) - YouTube
Having trouble running Python from your Mac's terminal? In this video, I'll show you exactly how to manually add Python to your PATH environment variable on ...
Published: April 5, 2026
๐ŸŒ
YouTube
youtube.com โ€บ watch
How To Install Python on Mac OS | Set Python PATH on Mac | Python Hello World! - YouTube
These are tools and services I personally use or have tested, and I highly recommend them for learning, productivity, and professional growth:Datacamp - Lear...
Published: December 18, 2024
Top answer
1 of 5
5

I just solved this problem by installing Python 3.2.2 on my Mac OS X Lion so I thought I would post how I did it in the hopes someone may find it helpful.

Firstly, I agree with shadesandcolour in that you should not modify the default copy of python that came with your mac because there could be scripts that may not work properly when run using the Python 3.0+ interpreter. Having said that, to install that latest Python (3.2.2 at the time of this post), you should first download the Python installer from the official website. Install as per normal. Run the "Update Shell Profile.command" file in /Applications/Python(ver) folder.

After python has been installed, you need to edit your path by typing "sudo nano /etc/paths" at the command line. Next, enter your password when prompted. Next just "cut" the line "/usr/local/bin" and "paste" it BEFORE the occurrence of "/usr/bin". Save the file, close any open terminals and run a new instance of terminal. Now when you type "python" at the command line, the shell will search through /usr/local/bin first and run the latest copy of python.

2 of 5
1

From my experience, using symlinks along with a properly ordered PATH is the way to have multiple versions of Python coexist in OS X or any other nix I can think of. OS X is just a little bit goofy, but it works the same way.

First get the full picture by running the following commands:

which python

Then:

ls -la /usr/bin/python*

and compare with:

ls -la /usr/local/bin/python*

See where the symlinks are pointing.

Based on the PATH you posted, since /usr/bin comes after /usr/local/bin and the others you are probably using the System python interpreter:

/usr/bin/python

If you installed python3.0 it will likely run as:

/usr/local/bin/python

Now that you know what is pointing where, and what interpreter is being loaded from the PATH, you can make the appropriate changes to the PATH and/or symlinks. You can then use the same techniques to confirm the proper changes.

For more good information about python installation on macOS see dive into python3 and farmdev.

๐ŸŒ
YouTube
youtube.com โ€บ watch
add python to path mac os - YouTube
Instantly Download or Run the code at https://codegive.com sure! here's a tutorial on how to add python to the path on macos, along with code examples:the p...
Published: March 13, 2024
๐ŸŒ
Opensource.com
opensource.com โ€บ article โ€บ 19 โ€บ 5 โ€บ python-3-default-mac
The right and wrong way to set Python 3 as default on a Mac | Opensource.com
Now that Python 3 is installed through pyenv, we want to set it as our global default version for pyenv environments: $ pyenv global 3.7.3 # and verify it worked $ pyenv version 3.7.3 (set by /Users/mbbroberg/.pyenv/version) The power of pyenv comes from its control over our shell's path.
๐ŸŒ
Codegive
codegive.com โ€บ blog โ€บ add_python_to_path_mac_os.php
Add python to path mac os
Add the PATH export line: 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"
๐ŸŒ
Real Python
realpython.com โ€บ lessons โ€บ adding-python-path-macos
Adding Python to PATH on macOS (Video) โ€“ Real Python
But if I want to keep my current window open, then source .zprofile and python3 --version now points to 3.14 and which -a ... 08:34 In the next lesson, youโ€™ll see how to do this process in Linux. And in the lesson after that, weโ€™ll look at how to modify PATH in Linux and Mac by editing the dotfile from the command line and understanding how the rest of that PATH gets formed if itโ€™s not inside of a dotfile.
Published: March 31, 2026
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Install Python on Mac OS and add to the PATH Variable|python tutorial | python for beginners - YouTube
Subscribe to our channel to get video updates. Hit the subscribe button above: """""Welcome to the magical world where coding meets simplicity. Installing Py...
Published: June 5, 2022
๐ŸŒ
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.