【发布时间】:2014-05-01 17:08:10
【问题描述】:
几个小时以来,我一直被一个奇怪的错误困住,在 Google 中搜索解决方案并失败了,可能是因为问题非常具体,但它实际上具有更广泛的含义,这就是我一直在努力修复的原因它。
我正在使用 Python 2.6 并且可以使用subprocess.call() 在普通 Python 终端甚至 iPython 终端中运行名为 STAMP 的程序:
>>>Import subprocess
>>>subprocess.call('stamp')
这很好,但是当我通过 sublime text 2 (ST2) 使用它的 sublimeREPL 插件 for python 或 iPython (Tools>sublimeREPL> 执行相同的事情时Python>...) 它失败并出现以下错误:
> Traceback (most recent call last): File "<stdin>", line 1, in
> <module> File "<string>", line 27, in <module> File
> "/usr/lib64/python2.6/subprocess.py", line 478, in call
> p = Popen(*popenargs, **kwargs) File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
> errread, errwrite) File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
> raise child_exception OSError: [Errno 2] No such file or directory
当您调用系统上未安装的程序时,它给出的错误相同。似乎自相矛盾的是,除了“stamp”之外,我测试过的任何其他已安装程序/命令都没有出现此错误(因此您会认为 sublimeREPL 工作正常),但运行 subprocess.call('stamp') 确实有效在本机 python 终端以及 iPython 中(所以你会认为 stamp 工作/安装正常)。我想到的唯一线索是我必须使用 g++ 安装 stamp
总结:
- subprocess.call('stamp') 在原生 python 终端中工作
- subprocess.call('stamp') 在 ST2 的 sublimeREPL python 终端中不起作用
- subprocess.call() 似乎在 sublimeREPL 或本机 python 终端中都可以正常工作
额外信息:
- Python 2.6.3
- 印章安装步骤:
第 1 步:安装 GNU 科学库。 从http://www.gnu.org/software/gsl/下载 将“include”和“lib”目录添加到 PATH。
第 2 步:编译 STAMP 代码。 使用如下命令:
g++ -O3 -o stamp Motif.cpp Alignment.cpp ColumnComp.cpp \ PlatformSupport.cpp PlatformTesting.cpp Tree.cpp \ NeuralTree.cpp MultipleAlignment.cpp RandPSSMGen.cpp \ ProteinDomains.cpp main.cpp -lm -lgsl -lgslcblas Note: if the GSL library is not in the PATH, add the appropriate directories using the -L and -I compiler options.第 3 步:测试一下!
【问题讨论】:
-
PATH 可能未在 sublimeREPL 终端内设置。使用完整路径来标记(可能是 /usr/bin/stamp 或 /usr/local/bin/stamp)有效吗?
-
@dano,stamp 的代码存储在
/home/ab108/software/STAMP.v1.2/code/中,并按照使用 g++ 的说明进行操作,似乎在使用 GNU 编译后,它将代码与别名stamp相关联,并且我已添加到路径,带有export PATH=$PATH:/home/ab108/software/STAMP.v1.2/code/。运行subprocess.call('/home/ab108/software/STAMP.v1.2/code/')时,我得到:OSError: [Errno 13] Permission denied -
你想要
subprocess.call('/home/ab108/software/STAMP.v1.2/code/stamp') -
成功了!!太感谢了!并感谢您在第一条评论中的解释
标签: python g++ sublimetext2 python-2.6 sublime-text-plugin