'subprocess.POpen in Pyton 3.10 [Errno 2] No such file or directory

I just upgraded my web app to Python 3.10, and the following used to work before:

ssh = subprocess.Popen(['scp', '-i', self.key, src, dest],
                                   shell=False,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

but now I am getting

[Errno 2] No such file or directory: 'scp'

What am I missing? Any suggestions?



Solution 1:[1]

Figured it out, needed to specify the full path to scp!!

So it would be:

ssh = subprocess.Popen(['/usr/bin/scp', '-i', self.key, src, dest],
                                   shell=False,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ramiro