-1

Updated Question. I was trying to add this directory "/usr/local/opt/python-3.9.0/bin" to PATH on raspberry pi 4 and so I edited the bash file by adding the line: PATH = "/usr/local/opt/python-3.9.0/bin $PATH". I now realized this was wrong. When path is echoed now by typing , I can only see that python 3.9.0 path. I am unable to edit the bash file again as all the commands to open it are not recognized. Is there a way to change this, that is to change back to the default path? How can I removed the PATH I added wrongly? Almost all the basic commands such as sudo apt update, sudo apt full-upgrade etc appears not to be working at the terminal again because of this. Thank you in advance.

2
  • 1
    path is separated by : not space Commented Jul 4, 2021 at 11:16
  • If you install it properly there is no need to edit the PATH (even though the official python.org binaries normally do this)
    – Milliways
    Commented Jul 4, 2021 at 11:55

1 Answer 1

4

As already mentioned by others you have to use a colon instead of a space to concatenate paths:

PATH=$PATH:/usr/local/opt/python-3.9.0/bin
or
PATH=/usr/local/opt/python-3.9.0/bin:$PATH

The problem now is that you have destroyed the default search path so programs and editors are not found or they cannot find their environment. To temporary fix it you can set the PATH by hand. Just export the default path:

rpi ~$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games

Now you should be able to use editors and other programs again and you can fix your problem.

2
  • I was trying to add this directory "/usr/local/opt/python-3.9.0/bin" to PATH on raspberry pi 4 and so I edited the bash file by adding the line: PATH = "/usr/local/opt/python-3.9.0/bin $PATH". I now realized this was wrong. When path is echoed now by typing , I can only see that python 3.9.0 path. I am unable to edit the bash file again as all the commands to open it are not recognized. Is there a way to change this, that is to change back to the default path? How can I removed the PATH I added wrongly? Basic commands such as sudo apt update, sudo apt full-upgrade are not working Commented Jul 9, 2021 at 16:19
  • Th comment above is the correct form of the question. Sorry for the errors in the original questions. I now know that I can buy a new SD card and install pi OS afresh. Thank you everyone. Commented Jul 9, 2021 at 16:20

Your Answer

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

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