MacOS – My terminal path in macOS SIerra is messed up

bashmacospathpythonterminal

Few months ago, I was trying to download pygame on mac.

It was very difficult but I finally did it through terminal using bash.

But after the download, I think there was some change on default path on my Mac's terminal.

I searched many solutions through this site, but I can't solve the problem and I think those solutions are not really fit to my problem.

When I open terminal,

Last login: Thu Jul 6 21:18:59 on ttys000 ojeonghuns-MacBook-Pro:~ hoon$

I can see this kind of message and i remember that i couldn't find the first line when i first use terminal.

and on that state, i cannot use command line like ls, cd .. etc

I can use only pwd as i know, and everytime when I want to use ls or cd, i have to export new path by entering this kind of command line,

export PATH=/usr/bin:/bin

This leads me to use every command line, but everytime when i close and re-open the terminal, i have to set path.

If I echo $PATH , my path is

/Library/Frameworks/Python.framework/Versions/3.6/bin:’/usr/local/bin:??

I think i download one or two additional Python versions on my Mac.

So is it possible to set default path ?

Oh, and when I try to figure out by typing open ~/.bash_profile

I see the error message of

Trace/BPT trap: 5

Best Answer

The system's standard path (configured in /etc/paths) is /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. If you want to add an additional path like /Library/Frameworks/Python.framework/Versions/3.6/bin to your user's PATH permanently you have to include the old $PATH in the export PATH line - either at the end or at the beginning - in your .bash_profile file:

  • export PATH="new_path:$PATH"
  • export PATH="$PATH:new_path"

Additionally your PATH contains some unwanted characters like or ? and doesn't have a closing quote ".


Open Terminal and enter:

/usr/bin/nano ~/.bash_profile

Change the line

export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:’/usr/local/bin:??...

to

export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH"

If the file contains another line with export PATH="..." squeeze the required parts into the above line.

Save the mod with ctrlO and quit nano with ctrlX

Quit and relaunch Terminal and enter echo $PATH which should reveal at least:

/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin