Home > Enterprise >  PYTHONPATH environment variable not saving on macOS
PYTHONPATH environment variable not saving on macOS

Time:04-15

Running echo $PYTHONPATH returns a blank line:

freddy@dave ~ % echo $PYTHONPATH

freddy@dave ~ %

echo $PATH returns properly

freddy@dave ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin: ...

.bash_profile for user freddy:

# Fig pre block. Keep at the top of this file.
export PATH="${PATH}:${HOME}/.local/bin"
eval "$(fig init bash pre)"

# Use Python 3.10, not homebrew
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"

export PATH="/opt/homebrew/bin:${PATH}"
source ~/.bash_profile

# Fig post block. Keep at the bottom of this file.
eval "$(fig init bash post)"% 

Why does echo $PYTHONPATH return nothing? And how do I assign it to my Python3.10 path?

  • I've tried restarting, this does not help
  • I've run source ~/.bash_profile (this just closes the terminal after execution though?)
  • A test variable: export TEST="TEST" also echos a blank line

As the comment suggests, I'm trying to use Python3.10 instead of my Homebrew installation, which is for some system packages

CodePudding user response:

I am using zsh, not bash.


I moved PYTHONPATH to .zshrc and it saves as an environment variable now.

However, I have opted for the pyenv setup. And have added the following to my .zshrc file:

eval "$(pyenv init --path)"

https://stackoverflow.com/a/69378384/14141223

  • Related