Python中文
首页
教程
问答
标签
搜索
登录
注册
Subprocess.call或Subprocess.Popen不能使用路径(Linux/Windows)中的可执行文件
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在编写一个程序,需要在Linux和Windows上运行,并使用路径中存在的可执行文件(带参数)。(假设)</p> <p>目前,我在windows中使用Subprocess.Call和Subprocess.Popen运行可执行文件时遇到问题。</p> <p>对于这样的代码,在windows 8中</p> <pre><code>def makeBlastDB(inFile, inputType, dbType, title, outDir): strProg = 'makeblastdb' strInput = '-in ' + inFile strInputType = '-input_type ' + inputType strDBType = '-dbtype ' + dbType strTitle = '-title ' + title strOut = '-out ' + os.path.join(os.sep, outDir, title) cmd = [strProg, strInput, strInputType, strDBType, strTitle, strOut] result = Popen(cmd, shell=True) </code></pre> <p>我在控制台中收到错误消息</p> <pre><code>'makeblastdb' is not recognized as an internal or external command, operable program or batch file. </code></pre> <p>即使我可以使用cmd.exe运行相同的命令 我得到了与shell=False相同的响应。</p> <p>如果可执行文件位于PATH环境变量中,我可以如何运行该命令?谢谢</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我自己一直在挣扎,直到找到<a href="http://bugs.python.org/issue17023" rel="noreferrer">this python bug report</a>。</p> <p>“如果将目录添加到Windows上的路径中,使目录用引号括起来,则子进程在其中找不到可执行文件。”因为Windows不需要引号,删除引号可以解决我的问题(在2.7中)。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在乒乓球比赛中预测球的轨迹,对于AI球拍预测?
5 回答
如何在乒乓球游戏中阻止球
9 回答
如何在乘法和模中不乘空间?
4 回答
如何在乘法和除以2个不同的数字之间进行交换?
6 回答
如何在也是数据一部分的单个字符上拆分大字符串
5 回答
如何在乾草堆中找到針,有更好的解決方案嗎?
6 回答
如何在事件wxWidgets中传递自定义数据
9 回答
如何在事件中使用lambda i=i?
5 回答
如何在事件中心只接收最近的数据
1 回答
如何在事件发生之前保持云函数运行?
3 回答
如何在事件发生后使页面重定向到同一页面
9 回答
如何在事件回调之间保持python生成器的状态
5 回答
如何在事件处理程序(pythonsocket、sphinx)中保留docstring
3 回答
如何在事件处理程序中更改wxRichTextCtrl的光标位置?
5 回答
如何在事件处理程序中访问外部对象?
7 回答
如何在事件循环中将协程打包为正常函数?
8 回答
如何在事件循环之外运行协同程序?
2 回答
如何在事件循环结束时为并发未来的所有线程调用类方法?
4 回答
如何在事件文件中只保留一份摘要?
3 回答
如何在事件模板中添加事件
3 回答