3

I have a Python script call.py to log in to another machine through ssh and execute another Python script saved on this machine, something like this

# call.py
import os

# log into user@host machine and execute python script
os.system("sshpass -p password ssh user@host '( python3 my_script.py )'")

but when I try to run it I get this error

Illegal instruction     (core dumped)  ( python3 my_script.py )

I tried a few things:

  • If I log into ssh and launch python3 my_script.py through the terminal it works
  • I also tried running the same call.py script without the ssh part, so trying to launch my_script.py on the same machine and it works

It seems that only the combination of ssh + python inside python that gives me this error. Any pointers on what could cause the error will be very much appreciated.

Edit: I didn't realize it would play a role, but I'm adding now the important detail that the target machine is an Nvidia Jetson board.

Otter_warrior
  • 193
  • 1
  • 12
  • "Illegal instruction" could mean that it's running an executable that was compiled for a different system. There could be differences in the `PATH` variable, causing a different executable to be run from the terminal vs. when run through ssh. Try using an absolute path like `/usr/bin/python3` instead. – Thomas May 25 '21 at 08:42
  • Thank you for your comment, it pointed me in the right direction! There is a variable that I had to define in the target machines to make OpenCV work. Now to make `my_script.py` work I had to define it before calling `python3` in the same command. – Otter_warrior May 26 '21 at 08:42

1 Answers1

3

I found the solution for my case, in case it can help someone else. As pointed out by Thomas, the problem was that I was working with different systems, in the specific my target machine was a Jetson while I was running ssh from my laptop.

On my Jetson board I had seen the Illegal instruction (core dumped) when trying to import OpenCV, to which the solution was to export OPENBLAS_CORETYPE=ARMV8 to the ~/.bashrc.

In order to make this work through ssh, I had to modify my command to call python this way:

OPENBLAS_CORETYPE=ARMV8 python3

and now it works!

Otter_warrior
  • 193
  • 1
  • 12