Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set user PATH permanently on Mac OS Catalina zsh shell

How do I set user PATH permanently to be able to access Pipenv from the zsh shell on Mac Catalina?

I am installing Pipenv for the first time. After successful installation, I cannot access it from the zsh shell. However, when I ran this code (I found somewhere else):

PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
PATH="$PATH:$PYTHON_BIN_PATH"

I am able to run Pipenv from the terminal but only for that instance. Because, when I close and reopen the terminal, it doesn't work again until I run the code over again.

User@User-- ~ % pipenv

Error

zsh: command not found: pipenv
like image 954
tundebosoro Avatar asked Oct 17 '19 18:10

tundebosoro


2 Answers

Using bash, you would have added PATH="$PATH:$(python3 -m site --user-base)/bin" to your .bash_profile, so that each bash session would have the proper directory to PATH.

In zsh, you would add that line to .zprofile instead.

like image 58
chepner Avatar answered Oct 07 '22 17:10

chepner


cd && touch .zprofile && open .zprofile

This command will create and open a .zprofile file, and every path you save in the file will be permanently available on the terminal.

Android SDK paths for examples:

export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

For macOS versions that are older than macOS Catalina use .bash_profile instead of .zprofile

like image 8
Guillaume250 Avatar answered Oct 07 '22 18:10

Guillaume250