2

i'm using paramiko to start a python script on my raspberry pi from my local machine. i can ssh into the rpi from the script just fine, but when i execute the command to run the script on the rpi, i get hit with a couple of module not found errors, for the user defined modules i'm importing in the script.

for reference, here's where it's being called (on my local machine):

    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    client.connect(address, username=usr, password=pwd)
    _, ss_stdout, ss_stderr = client.exec_command('export PATH=$PATH:/home/pi/berryconda3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games && echo $PATH && cd /home/pi/Team2 && python rpi-main.py')
    r_out, r_err = ss_stdout.readlines(), ss_stderr.read()

    print(r_err)
    if len(r_err) > 5:
        print(r_err)
    else:
        print(r_out)
    client.close()

The other commands execute fine, but when it gets to python rpi-main.py, I get

from MQTT.sub import client_mqtt\nImportError: No module named MQTT.sub

MQTT.sub is a user defined module that I import. It works fine when I run this command via regular ssh, or directly on the raspi, so I don't know what's going wrong here. I can also import regular python modules (ie multiprocessing) without any errors. Any help/guidance would be appreciated. Thanks!

0 Answers0