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

标签 python import

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

import sys
import scipy.io

sys.exit(2)

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

知道为什么导入 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')

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

最佳答案

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

一个奇怪的观察结果是

the bug disappears when importing weave.

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

关于python:导入 scipy.io 似乎会阻止 sys.exit() 正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10615917/

相关文章:

python - Python套接字错误

python - 为什么 MySQL 数据库在 SQLAlchemy 查询期间会出现 "go away"?

c++ - 有没有使用inpout.dll的开源程序?

python - 从文件夹导入模块 (Python)

python - 无法在 Windows 上使用 Eclipse 导入由 f2py 生成的文件

python - 在 Python 中使用 BeautifulSoup 库

python - 用键打印字典中的最高值

python - Pandas 数据框中每一行的随机值

java - 抑制 Java 中不推荐使用的导入警告

带有来自 NuGet 的 QuickGraph 包的 C#