Python Error: Cannot Find The File Specified
This is my body of code: os.chdir('C:\\Users\\Desktop') rc = subprocess.call(['7z', 'a', 'test', '-y', 'myarchive.zip'] + [r'device teams.txt']) It gives me
Solution 1:
Based on your comments, the problem isn't the txt
file path, it's that the command 7z
cannot be found. You can check this by just calling rc = subprocess.call(['7z'])
: the error The system cannot find the file specified
persists.
Here's how you can achieve the same thing using PowerShell for example:
import os
import subprocess
os.chdir("C:\\Users\\Username\\Desktop")
rc = subprocess.call("powershell Compress-Archive -Path 'device teams.txt' -DestinationPath archive.zip")
Post a Comment for "Python Error: Cannot Find The File Specified"