0

I am trying to access the curl executable on my computer using a subprocess call, but when I do so, I get the following error:

WindowsError: [Error 2] The system cannot find the file specified

my code looks as follows

path = 'C:\\Users\\Username\\AppData\\Local\\Continuum\\Anaconda2\\Library\\bin\\curl.exe subprocess.call([path])

I know the path is correct, is there a reason that my script is balking at this? As you can see, I am running the Anaconda2 Python Interpreter, not the standard one from Python.org

1
  • Check that os.path.exists(path) is true. I assume you're replacing "UserName" with the actual user name, but try to generalize this to arbitrary users. For example: anaconda_path = os.path.join(os.environ['LOCALAPPDATA'], 'Continuum', 'Anaconda2'); curl_path = os.path.join(anaconda_path, 'Library', 'bin', 'curl.exe'). Commented Jul 1, 2016 at 14:05

1 Answer 1

2

Take a step back and do some sanity checks. Here are some steps to try.

  • Copy the path in your script, and paste it into the file explorer (remove the escape characters) and verify that the path is indeed correct.
  • Verify that you have proper permissions to the path
    * Copy the executable (curl.exe) to a same location your python script is at, this eliminates the need to specify a path (sanity check)

    import subprocess

    path = 'curl.exe'
    subprocess.call([path])

If this works, you can then move it your expected path and verify

Sign up to request clarification or add additional context in comments.

1 Comment

eryksun is absolutely correct. I had written a quick test locally, which worked but I had curl in my path which of course is not true in the general case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.