- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 Windows 中运行以下命令:
from subprocess import check_output
check_output(["dir", "D:/C_Drive/Desktop/Kaggle"])
我遇到以下问题,“D:/C_Drive/Desktop/Kaggle”当前是我桌面上的一个文件夹。
-- WindowsError Traceback (most recent call last) <ipython-input-9-6f7efc3bbf8c> in <module>()
10
11 from subprocess import check_output
---> 12 check_output(["dir", "D:/C_Drive/Desktop/Kaggle"])
13
14 # Any results you write to the current directory are saved as output.
C:\Program Files\Anaconda2\lib\subprocess.pyc in check_output(*popenargs, **kwargs)
565 if 'stdout' in kwargs:
566 raise ValueError('stdout argument not allowed, it will be overridden.')
--> 567 process = Popen(stdout=PIPE, *popenargs, **kwargs)
568 output, unused_err = process.communicate()
569 retcode = process.poll()
C:\Program Files\Anaconda2\lib\subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
709 p2cread, p2cwrite,
710 c2pread, c2pwrite,
--> 711 errread, errwrite)
712 except Exception:
713 # Preserve original exception in case os.close raises.
C:\Program Files\Anaconda2\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
957 env,
958 cwd,
--> 959 startupinfo)
960 except pywintypes.error, e:
961 # Translate pywintypes.error to WindowsError, which is
WindowsError: [Error 2] The system cannot find the file specified
最佳答案
添加shell=True
将会被罚款
from subprocess
import check_output print(check_output(["dir", "D:\\C_Drive\\Desktop\\Kaggle"],shell=True).decode("utf-8"))
关于python - 系统找不到为 check_output 指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40213891/
我正在玩子流程库。我可以执行 v = subprocess.check_output("ls") 而且效果很好。但是,当我通过 SSH 连接到一台机器上并想要执行 hadoop 命令时, v = su
我有使用 subprocess.check_output 的代码很好,我不得不重新安装 Ubuntu 16.04,然后它提示它现在找不到属性 check_output。 import subproce
我正在尝试为我正在编写的 configure.py 脚本检索 CPU 功能列表。在 shell 中,我执行如下操作: $ cat /proc/cpuinfo|grep flags|head -1|cu
#!/bin/python import subprocess import traceback import logging output_file = "/Users/abhabhin/Deskt
我在此处执行此代码时遇到问题 subprocess.check_output(['ps -ef | grep ftp | wc -l'],env=environ,shell=True) 当我从终端执行
首先,我阅读了尽可能多的与 subprocess.check_output() 相关的问题,但仍然很难找出问题所在。 如果我在 shell 中执行 kill -l 1,我会得到 1 对应的信号名称,即
我正在使用python来运行Youtube-dl ,一款用于从 YouTube 和其他网站下载视频的软件。我专门用它从 YouTube 视频下载音频。我可以通过使用 check_output() 执行
我正在使用 subprocess.check_output 运行 Xyce(SPICE 模拟器)仿真,因为我想使用它的结果进行进一步分析。 这是我使用的代码: x=subprocess.check_o
我正在尝试在 Python 2.7.5 中运行以下代码: output = subprocess.check_output(commandList) print (len(output)) 我的命令列
我正在通过 subprocess.check_output() 执行命令,因为我希望它的 o/p 存储在缓冲区中。 现在,在执行此操作时,如果命令失败或出现任何错误,则会给我的整个应用程序带来问题。
当我在 Subprocess 模块中使用 check_output 时,我从 Python shell 中得到了这个输出错误: AttributeError: 'module' object has
我正在尝试使用 mediainfo 读取视频文件的持续时间。这个 shell 命令有效 mediainfo --Inform="Video;%Duration/String3%" file 并产生类似
我在使用 subprocess.check_output() 时遇到了一些奇怪的问题。起初我只是使用 subprocess.call() 并且一切正常。然而,当我简单地将 call() 切换为 che
我想调用一个脚本,将字符串的内容通过管道传输到它的标准输入并检索它的标准输出。 我不想接触真正的文件系统,所以我不能为它创建真正的临时文件。 使用 subprocess.check_output 我可
prules=subprocess.check_output("perl ruleFinder.pl "+datasetfile+" "+myrulepath, shell=True)##call a
用crontab执行python脚本时,脚本缺少环境变量。 该脚本调用一个可执行文件,某些 Linux 发行版在 /usr/bin 下提供,而其他在 /sbin 下提供。 subprocess.che
我在我的 Raspberry Pi 3 上运行下面的代码行,并期望向用户显示输出。 (这只是我学习曲线中的一个测试) #test.py import subprocess output = subpr
我正在尝试获取的输出 dmesg | grep -i 'bios' 我已经试过了: dmsg = subprocess.check_output("dmesg | grep -i 'bios'").d
我正在使用 subprocess.check_output 调用 MS DOS 命令行应用程序以从应用程序返回 stdout 字符串。 check_ouput 的返回是关于刚刚运行的命令的信息,一个新
我试图捕获 check_output 的返回值,而不是让它自动打印到命令行。不幸的是,我的解决方案不起作用,我不知道为什么。我已经包含了我的代码及其输出: #!/usr/bin/env python3
我是一名优秀的程序员,十分优秀!