Hello stack overflow users,
I'm having a great deal of difficulty trying to get mypy to work correctly with Popen. Essentially I'm writing a test suite that utilizes mypy but cannot seem to get valid output on my build machine.
The line in question is the following:
p = subprocess.Popen(['mypy'] + extra_args + python_files, env=my_env, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIP)
extra_args
specifies the cache-dir and traceback, and python_files
are the files in question to be tested. I'm fairly confident that neither of these arguments are the issue, as I've played around with these and made no progress.
This file is in a git repo, and I've cloned it and put it on a build box. Locally it's not a problem -- I get valid, mypy output indicating errors. However, on my build machine I get the OSError: [Errno 2] No such file or directory
error. The full error message is as follows:
Traceback (most recent call last):
File "mypath/run_mypy.py", line 83, in <module>
main()
File "mypath/run_mypy.py", line 70, in main
p = subprocess.Popen(['mypy'] + extra_args + python_files, env=my_env, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
myotherpath/build-stack.mk:162: recipe for target 'mypy' failed
I've tried adding shell=True
but this resulted in all mypy errors begin surpressed, plus is considered bad style/security concern.
My guess/thought is that maybe mypy somehow isn't in the path that popen uses without the shell but I'm really not sure.
Anyway I'm at a huge loss here -- any help would be appreciated.
Okay, just figured out my problem and it was fairly obvious... Whoops!
This fixed it: python3 -m pip install -U mypy==0.530
Turns out I didn't have mypy
installed on the box. The error message led me astray because I thought it was referring to one of the arguments I'd passed, not the actual command. Hopefully this is helpful to someone in the future.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.