0

I am trying to get a python code to run on boot on the raspberry pi. I added the following line to the .bashrc file at the end of the file:

sudo python3 /home/pi/code.py

The pi uses python2 to run the code instead of python3. Why is this happening and how can I make it run python3?

Thanks

1 Answers1

1

.bashrc is NOT intended to run scripts.

It is run each time a non-login interactive shell is started and is used to configure the shell.
~/.bashrc: executed by bash(1) for non-login shells.

There are many ways of running scripts, depending on what you are trying to do. See https://raspberrypi.stackexchange.com/a/47537/8697 for an example.

(There are other problems with the script, but as you shouldn't use it for this purpose, not relevant.)

Milliways
  • 59,890
  • 31
  • 101
  • 209