python log模块导致系统挂起_为什么一个简单的Python / Haskell / etc程序在导入时冻结/挂起?...

(我知道这是一个基本的/新手的错误.但我怀疑我是第一个或最后一个犯这个错误的人……所以我会在这里记录下来,所以未来像我一样可以谷歌吧.)

这些脚本冻结,因为它们实际上是shell脚本.这些shell脚本实际上正在运行导入命令行程序…由ImageMagick包提供:

$sh freeze.hs

C-c

$which import

/usr/bin/import

$man import | head -10

... import - saves any visible window on an X server and outputs it as an image file.

$import screenshot.ps

... and here notice the mouse icon changes to a cross-hair icon ...

... so then press the mouse button to finish this operation ...

$file screenshot.ps

screenshot.ps: PostScript document text conforming DSC level 3.0, Level 1

因此,我向ImageMagick工作人员致敬,他提供了一个很好的,无声的命令行操作.

至少在各种基于Linux的操作系统上,这些脚本会触发导入命令行程序的操作. BSD,Windows,MacOS等可能会有不同的反应.

以下是使用Python解释器和ghc编译器的脚本的正确操作:

$python freeze.py

hello

$runghc freeze.hs

"hello"

或者,包括#! shebang:

$ls -l no_freeze.py

-rwx------ 1 rick rick 46 Oct 27 11:44 no_freeze.py

$cat no_freeze.py

#!/usr/bin/env python

import re

print "hello"

$./no_freeze.py

hello

Haskell也一样:

$ls -l no_freeze.hs

-rwx------ 1 rick rick 68 Oct 27 11:26 no_freeze.hs

$cat no_freeze.hs

#!/usr/bin/env runghc

import Text.Regex.Posix

main = print "hello"

$./no_freeze.hs

"hello"

在我的MacOS计算机上,我收到此错误,因为我的X11设置的某些部分尚未完成.对于那些没有安装X11的人,我想你会得到命令not found error.

$import screenshot

Version: ImageMagick 6.9.5-0 Q16 x86_64 2016-07-02 http://www.imagemagick.org

...

import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值