2

I built and installed python3.8 in raspbian and changed PATH

export PATH=$HOME/.local/bin/:$PATH

I run

>>which python3
/home/pi/.local/bin//python3
>>python3 --version
Python 3.8.0
>>whereis python3
python3: /usr/bin/python3.7m-config /usr/bin/python3.7m /usr/bin/python3.7 /usr/bin/python3.7-config /usr/bin/python3 /usr/lib/python3.7 /usr/lib/python3 /etc/python3.7 /etc/python3 /usr/local/lib/python3.7 /usr/include/python3.7m /usr/include/python3.7 /usr/share/python3 /home/pi/.local/bin/python3.8-config /home/pi/.local/bin/python3.8 /home/pi/.local/bin/python3 /usr/share/man/man1/python3.1.gz

however when I run

>>sudo python3 --version
Python 3.7.3
>>sudo which python3
/usr/bin/python3

how can I change sudo python3 to point to 3.8

david
  • 123
  • 1
  • 5

1 Answers1

1

You can use sudo -E COMMAND in order to preserve the enviroinment of your user. In your case:

sudo -E python3 --version

If the problem is still here, you can use the following command to override the path only for the selected command:

sudo "PATH=$PATH" python3 --version
# OR
sudo env "PATH=$PATH" python3 --version
alessiosavi
  • 347
  • 2
  • 9