python:导入scipy.io似乎阻止sys.exit()正常工作

时间:2012-05-16 09:42:09

标签: python import

在Windows下,执行以下Python脚本,我得到的ERRORLEVEL为0而不是预期的2。

import sys
import scipy.io

sys.exit(2)

如果我删除了导入scipy.io,我得到了2的正确ERRORLEVEL ......

知道为什么导入scipy.io会导致这样的问题吗?

PS:windows 7,python 2.72,scipy 0.10.1

在sys.exit调用之前调用help(sys.exit)返回以下内容(这似乎很好):

Help on built-in function exit in module sys: 

exit(...) 
    exit([status]) 

    Exit the interpreter by raising SystemExit(status). 
    If the status is omitted or None, it defaults to zero (i.e., success). 
    If the status is numeric, it will be used as the system exit status. 
    If it is another kind of object, it will be printed and the system 
    exit status will be one (i.e., failure).

如果我打电话

sys.exit('Something wrong')

打印字符串,但系统仍然以ERRORLEVEL而不是预期的1返回0。

1 个答案:

答案 0 :(得分:1)

这似乎是由于SciPy中的一个错误。以下是一些相关的门票(只有第一张门票仍然开放):

有一个奇怪的观察结果

  

导入编织时错误消失。

也许尝试导入scipy.weave以查看此解决方法是否有帮助?