10

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
2
  • Just do a brew install pipenv
    – pissall
    Oct 17, 2019 at 18:21
  • See the section "STARTUP/SHUTDOWN FILES" in man zsh for an overview of the files zsh looks at on startup. The process is both broader and slightly different from how bash works.
    – chepner
    Oct 17, 2019 at 20:10

4 Answers 4

18

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.

1
8
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

3

At macOS Catalina ver: 10.15.3, i modified the ~/.zshrc file and worked for me for the default terminal (zsh).

I had created the ~/.bash_profile file and nothing changed.

2

If you're using Homebrew, then another option is to install pipenv like so:

brew install pipenv

This installs it globally. Since pipenv can manage even different python versions via pyenv, it's preferable to have it set up like this instead of installing it only for a specific python version using pip.

1
  • This works too, just that I didn't want to install it globally. I wanted to do a user installation to avoid breaking any system wide packages as I am new to programming. Ended up adding the PATH using .zprofile on zsh Oct 17, 2019 at 21:34

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.