2

I'm following the retrieve and rank tutorial and everything is good until the train.py script - I get an error message below:

Generating training data...
Traceback (most recent call last):
  File "./train.py", line 83, in <module>
    process = subprocess.Popen(shlex.split(curl_cmd), stdout=subprocess.PIPE)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Any ideas?

Bhargav Rao
  • 41,091
  • 27
  • 112
  • 129
  • Are there any links to what you're talking about, i.e. the tutorial or `train.py`? From the error message you probably don't have [**`cURL`**](https://curl.haxx.se/download.html) installed on your path. – Peter Wood May 14 '16 at 05:36
  • On [this page](https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/retrieve-rank/get_start.shtml) it says you need a Bluemix account, cURL, and Python. It tells you which version of cURL to install and where to get it. – Peter Wood May 14 '16 at 05:44
  • Thanks Peter. I have created a Bluemix account and followed the tutorial. Also installed cURL and Python (version 2, as required to run train.py. It is only when I run train.py I got this error. – Benjamin Liu May 14 '16 at 05:50
  • If you enter `curl -V` at the command prompt what does it say? – Peter Wood May 14 '16 at 05:51
  • Thanks again Peter. I am at home now but I will find out my curl version tomorrow. Do you think it is possible that because I use my university computer to run Python and there are some restrictions on uni computer which caused the error? – Benjamin Liu May 14 '16 at 07:50
  • I think cURL is not on your path. You need to set path either before running your script or in the script. See https://stackoverflow.com/questions/1681208/python-platform-independent-way-to-modify-path-environment-variable for how to do it in the script, or https://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows to set in the command prompt – Peter Wood May 14 '16 at 18:49
  • Thanks Peter. My curl version is as follows: C:\>curl --version curl 7.48.0 (x86_64-pc-win32) libcurl/7.48.0 OpenSSL/1.0.2h nghttp2/1.10.0 Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IPv6 Largefile NTLM SSL HTTP2 – Benjamin Liu May 14 '16 at 21:21
  • I run train.py under my user directory. I suspect that because curl is in C drive, when I run train.py, it will not recognize curl command in train.py. I am now following your comments to see how to set a path in the script. Thanks again. – Benjamin Liu May 14 '16 at 21:24
  • 1
    I added curl.exe into my user directory and now train.py runs properly. Thanks Peter for your help, much appreciated! – Benjamin Liu May 14 '16 at 21:41

1 Answers1

1

@peter-wood answered the question in the comments.

In this case, the unfriendly error message:

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

was caused by curl not being on the PATH. train.py expects the curl command to be available and on the PATH.

Bruce Adams
  • 433
  • 2
  • 5
  • Just to note, as it tripped me up 'till I realised what I had done: It needs to be in the path of the environment calling cURL - so if you are executing the script from something / somewhere that may not share the same environment as your userid at the command line, you may need to take steps to ensure the PATH for the executing environment also has cURL in it somewhere. – Matt Warren Jun 27 '16 at 12:58