6

So basically I tried to make changes to my path in my .bash_profile and save the changes but whenever I restart my terminal, it changes back to the default path and not the one ive set in .bash_profile

Ive tried to use the source ~/.bash_profile command but which i thought helped but somehow, when i restart the terminal, it doesnt change to the settings ive placed in .bash_profile

PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

alias python=python3
alias pip=pip3

The expected output is when i type python in mac os terminal it should appear as python 3.7 and not python 2

chepner
  • 497,756
  • 71
  • 530
  • 681
Rafie Suib
  • 79
  • 1
  • 5
  • Try sourceing your bashrc profile. Discussed here: https://stackoverflow.com/questions/21211281/source-command-on-mac – Brandon Nov 02 '19 at 17:50
  • 2
    Are you sure you are using `bash`? If this is a new account on macOS 10.15, you are probably using `zsh` instead. – chepner Nov 02 '19 at 18:01

5 Answers5

12

Put your commands into ~/.zshrc file on macOS Catalina

nano ~/.zshrc 
Mikhail Sharin
  • 3,661
  • 3
  • 27
  • 36
10

Starting with macOS Catalina, the default interactive shell is zsh:
https://support.apple.com/en-us/HT208050

Make sure that you are using bash as your login shell.
You can check what is your login shell with the command echo $SHELL. If the result is /bin/bash, then you are using bash as your login shell. Otherwise you can change it with the command chsh -s /bin/bash.

André Panisson
  • 876
  • 9
  • 22
  • 1
    Got this after the Big Sur update 11.0.1, the default interactive shell is forced to zsh. Thats why my bash_profile changes weren't working, they kept resetting after restarting terminal. After issuing your fix, it finally worked. Thanks so much – IT-Girl Dec 02 '20 at 09:54
1

I think what you are trying to do should be in .bashrc file, and not .bash_profile

also maybe your .bashrc file override those aliases

you can read more about the difference of them here

Reznik
  • 2,663
  • 1
  • 11
  • 31
  • 2
    On macOS, a terminal window opens a login shell, not an ordinary interactive shell, since the terminal emulator itself isn't being started in an environment set up by a login shell. – chepner Nov 02 '19 at 18:14
1

The solution that fixed this problem for me was changing the shell terminal preferences to open shell with command(complete path)

But thank you all for the replies greatly appreciated

Rafie Suib
  • 79
  • 1
  • 5
0

I'm using Catalina, and here is what works for me 1.open with vim - vi .zprofile 2.edit the content 3.save the profile file - source .zprofile

zengse
  • 11
  • 2