Terminal -bash: command not found errors

Multi tool use
Terminal -bash: command not found errors
I messed up something in my programming a few days ago that screwed up my terminal. My terminal now gives me the a bash error message with basic functions like ls, cd, or ssh. The error looks like this: -bash: ls: command not found , where the "ls" can be replaced with any shell command.
The only way I have found to make my terminal function, is by inputting: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin" into ever terminal window I open, which can get very tedious.
It also refuses to run Python or Jupyter unless I type the aforementioned command in the terminal window first.
Go files also fail to run in terminal, and gives me a similar error message: -bash: go: command not found. This can be overcome by inputting: export PATH=$PATH:/usr/local/go/bin into the terminal window first.
I'm really worried about what is going on in my computer, and need my terminal to keep functioning in order for me to finish and pass this course (introduction to computer programming). Does anyone have any ideas as to what the problem may be, and how I could go about solving it?
Any help/advice would be greatly appreciated!!!
EDIT: I'm not sure if it is relevant, but I am using a Mac, and these problems started to occur after I attempted to download pygame (I say "attempted" because I never got a working version of pygame installed, though I did download several things in the process (XQuartz and a bunch of stuff from homebrew).
1 Answer
1
Check your .profile
or .bashrc
: one of those files might initialize your PATH incorrectly.
.profile
.bashrc
Set your PATH
manually, then cd ~
, and edit those two files to fix your PATH.
PATH
cd ~
.profile and .bashrc
Thank you for your help, I really appreciate it! Could you also please explain how I would check my .profile or .bashrc, and how I would make sure that my path is correct? Sorry, but I'm still very new to programming (still have less than a month of total experience). Thanks :)
– Percy_Cucumber
Jul 2 at 4:50
@Percy_Cucumber One way to debug that is to add
echo $PATH
after each line of your .bashrc and .profile. That way, at the next login, you can see how your PATH evolves, and pinpoint the moment it "goes wrong".– VonC
Jul 2 at 4:51
echo $PATH
Thanks, that seems to have isolated the problem. When I run echo $PATH I get: /Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:’/usr/local/bin:??. I'm guessing that the "??" means that it the path gets lost / goes wrong there?
– Percy_Cucumber
Jul 2 at 4:57
@Percy_Cucumber simply set the PATH correctly by adding in your file (where you detected the issue) an export PATH=...:/usr/local/bin:/usr/bin:/bin:/usr/sbin (replace ... by the other folders you want to add)
– VonC
Jul 2 at 5:00
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
.profile and .bashrc
may be hidden. Use Ctrl-H to toggle setting.– peterSO
Jul 2 at 4:39