简体   繁体   English

尝试运行mypy时,在popen上出现“ OSError:[Errno 2]没有这样的文件或目录”

[英]Getting 'OSError: [Errno 2] No such file or directory' on popen when trying to run mypy

Hello stack overflow users, 你好堆栈溢出用户,

I'm having a great deal of difficulty trying to get mypy to work correctly with Popen. 我在尝试使Mypy与Popen一起正常工作时遇到很多困难。 Essentially I'm writing a test suite that utilizes mypy but cannot seem to get valid output on my build machine. 本质上,我正在编写一个使用mypy的测试套件,但似乎无法在构建机器上获得有效的输出。

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. extra_args指定cache-dir和traceback,而python_files是要测试的相关文件。 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. 该文件位于git仓库中,我已将其克隆并放置在构建框中。 Locally it's not a problem -- I get valid, mypy output indicating errors. 在本地这不是问题-我得到有效的mypy输出,指示错误。 However, on my build machine I get the OSError: [Errno 2] No such file or directory error. 但是,在我的构建计算机上,我收到OSError: [Errno 2] No such file or directory错误。 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. 我尝试添加shell=True但这导致所有mypy错误开始被抑制,再加上不良的样式/安全问题。

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. 我的猜测/想法是,也许mypy某种程度上不在没有外壳的情况下popen使用的路径,但是我真的不确定。

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 修复此问题: python3 -m pip install -U mypy==0.530

Turns out I didn't have mypy installed on the box. 原来我没有在mypy安装mypy 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. 希望这对将来的人有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取OSError:[Errno 2]没有这样的文件或目录 - Getting OSError: [Errno 2] No such file or directory 尝试运行openalpr错误,但遇到此错误OSError:[Errno 2]没有这样的文件或目录 - Trying to run openalpr error but this error encounter OSError: [Errno 2] No such file or directory Python Popen shell = False导致OSError:[Errno 2]没有这样的文件或目录FFREPORT - Python Popen shell=False causes OSError: [Errno 2] No such file or directory FFREPORT Python:subprocess.Popen返回OSError:[Errno 2]没有这样的文件或目录 - Python: subprocess.Popen returns OSError: [Errno 2] No such file or directory Python:OSError:[Errno 2] subprocess.Popen上没有这样的文件或目录 - Python: OSError: [Errno 2] No such file or directory on subprocess.Popen Python Popen shell = False导致OSError:[Errno 2]没有这样的文件或目录 - Python Popen shell=False causes OSError: [Errno 2] No such file or directory subprocess.Popen:仅在Linux上,“ OSError:[Errno 2]没有这样的文件或目录” - subprocess.Popen: 'OSError: [Errno 2] No such file or directory' only on Linux OSError: [Errno 2] 没有那个文件/目录 - OSError: [Errno 2] No such file/directory 循环遍历目录中的文件时如何收到此错误? “OSError: [Errno 2] 没有这样的文件或目录” - How am I getting this error when looping through files in a directory? "OSError: [Errno 2] No such file or directory" OSError:[Errno 2]没有这样的文件或目录–尝试重命名文件时,Python不接受变量 - OSError: [Errno 2] No such file or directory – Python won't accept a variable when trying to rename files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM