I'm currently working on a project that requires me to use a python subprocess to execute "i2cset" on a Raspberry Pi2 through SSH but my code keeps telling me that my Raspberry Pi can't find "i2cset". When I tried to run this code

import subprocess
subprocess.run("ssh -t pi@ /bin/bash -ic 'ls; echo $PATH'", shell = True)

to debug (yes I need my command to be that "complicated" because I need it to load the .bashrc file and it won't otherwise), it returned me the list of files and this PATH content:


As you can see, the "/usr/sbin" that contains the "i2cset" command doesn't exist. What I find weird is that the /etc/profile sets a much bigger default PATH (including /usr/sbin).

Does anyone have any idea why this happens ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.