Reputation: 13
I am trying to run command like 'sed', 'pwd' using subprocess module in PyCharm(installed on Windows 10). But it is giving me error as below. Though same codes are working fine in VS Code.
import subprocess
subprocess.call('pwd')
Traceback (most recent call last): File "C:\Users\name\something.py", line 14, in subprocess.call('pwd') File "C:\Users\name\Miniconda3\envs\local_test3\lib\subprocess.py", line 339, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\name\Miniconda3\envs\local_test3\lib\subprocess.py", line 800, in init restore_signals, start_new_session) File "C:\Users\name\Miniconda3\envs\local_test3\lib\subprocess.py", line 1207, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
This is happening for any command I am trying to run through subprocess. And subprocess import is working fine, just the subprocess.call() is giving issues.
Please let me know if any leads on this. I tried several things, but not able to resolve the issue yet. Thanks.
Edit: I am getting same error with any command I am passing to subprocess.call().
subprocess.call("echo hello world")
Upvotes: 0
Views: 798
Reputation: 112
from the error I can see that you are using a windows machine, and when I test it windows don't have a past working directory command or the "pwd" command on cmd, try calling in subprocess.call("echo hello world")
just to make sure everything is working
Upvotes: 0