-1

I'm trying to open zip in terminal in python using subprocess, but I'm getting an error.

FileNotFoundError: [Errno 2] No such file or directory.

my purpose is to see if the process is successful or unsuccessful after opening the zip file and to print it.

Also my code:

from subprocess import run
output = run("unzip -P password /Users/username/Desktop/something.zip -d /Users/Desktop/Desktop/something", capture_output=True).stdout
print(output)

How can I fix the problem?

JeffUK
  • 4,107
  • 2
  • 20
  • 34
dadaturk
  • 29
  • 5
  • 2
    Does this answer your question? [Python subprocess.Popen() error (No such file or directory)](https://stackoverflow.com/questions/30010939/python-subprocess-popen-error-no-such-file-or-directory) – mkrieger1 Jun 15 '21 at 13:14

1 Answers1

0

Change

output = run("unzip -P password /Users/username/Desktop/something.zip -d /Users/Desktop/Desktop/something", capture_output=True).stdout

to

output = run(["unzip", "-P", "password", "/Users/username/Desktop/something.zip", "-d", "/Users/Desktop/Desktop/something"], capture_output=True).stdout
JakobDev
  • 142
  • 1
  • 8