reorx / httpstat

curl statistics made simple
MIT License
5.98k stars 384 forks source link

'failed to create process' after PIP install - Possible Python 3 Compatibility Issue? #24

Closed SWBennett06 closed 4 years ago

SWBennett06 commented 7 years ago

Installed via PIP on two separate computers running Windows 10 with Python 3.5.2 and Python 3.5.0 and attempted httpstat google.com in the command line and received 'failed to create process'. Navigated directly in the command line to the default Python scripts folder and ran py httpstat-script.py google.com and received the following on both machines: Traceback (most recent call last): File ".\httpstat-script.py", line 9, in <module> load_entry_point('httpstat==1.2.1', 'console_scripts', 'httpstat')() File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\site-packages\httpstat.py", line 221, in main p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=cmd_env) File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\subprocess.py", line 1224, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

Ran repair on my Python installation and retried. Uninstalled and reinstalled Python (using elevated privileges) and retried. No positive effect.

An attempt on a third Win10 computer with both Python 3.5.1 and Python 2.7 installed worked without issue. Installed via PIP and httpstat google.com ran correctly. Running the script directly on that machine with either version of Python also works without issue.

reorx commented 7 years ago

This seems like curl is not installed in the windows, can you make sure whether curl is installed or not in the first and second windows?

Since httpstat is just a wrapper around curl, it relies on it very deeply. But as curl may not installed on every windows (though it's available in almost every unix), it makes an obstacle to use httpstat on it. I suggest using the go version of httpstat which has windows binary execution included: https://github.com/davecheney/httpstat/releases , there's no installation or any programming environment needed, just download and run it would be OK.

SWBennett06 commented 7 years ago

Thanks for the quick response. Curl is definitely installed and works without issue. I was able to use the Node implementation off httpstat with no issue.

reorx commented 7 years ago

I tried again on my windows vm, but could not reproduce your situation, can you try to run this script on your machines that encounter the problem? I want to exclude all the other factors only to take a look on how curl is executed.

test_curl.py:

#!/usr/bin/env python
# coding: utf-8

import sys
import subprocess

PY3 = sys.version_info >= (3,)

if PY3:
    xrange = range

def run_curl(curl_bin):
    print('run curl: {}'.format(curl_bin))
    cmd = [curl_bin, 'https://www.google.com']
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = p.communicate()
    if PY3:
        out, err = out.decode(), err.decode()
    print('stdout and stderr: {}, {}'.format(out, err))

if __name__ == '__main__':
    curls = ['curl', 'curl.exe']

    for i in curls:
        run_curl(i)
reorx commented 4 years ago

Closed due to no response and reproduction.