突然之间,很多 python 程序都出现了相同的错误

2014-11-28 22:19:08 +08:00
 abccba
Gentoo Linux环境,今天突然发现很多python程序都不能用了:例如pip/equery/markdown2,还有其它众多python程序

重现问题:
在终端里直接输入pip或者equery或者markdown2,不用任何参数,就能看到相同的错误输出。

不知道是哪里出了问题。。。

执行`equery`时的错误输出如下:(执行pip/markdown2时结果一样,除了/usr/bin/xxx那几句)

Usage: /usr/bin/equery [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]
[-O <options>] [-P <option=value>] [-o <outfile>] [<infile>]

/usr/bin/equery -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]
/usr/bin/equery -L [<which> ...]
/usr/bin/equery -N <filename>
/usr/bin/equery -H <type> <name>
/usr/bin/equery -h | -V

Highlight the input file and write the result to <outfile>.

If no input file is given, use stdin, if -o is not given, use stdout.

<lexer> is a lexer name (query all lexer names with -L). If -l is not
given, the lexer is guessed from the extension of the input file name
(this obviously doesn't work if the input is stdin). If -g is passed,
attempt to guess the lexer from the file contents, or pass through as
plain text if this fails (this can work for stdin).

Likewise, <formatter> is a formatter name, and will be guessed from
the extension of the output file name. If no output file is given,
the terminal formatter will be used by default.

With the -O option, you can give the lexer and formatter a comma-
separated list of options, e.g. ``-O bg=light,python=cool``.

The -P option adds lexer and formatter options like the -O option, but
you can only give one option per -P. That way, the option value may
contain commas and equals signs, which it can't with -O, e.g.
``-P "heading=Pygments, the Python highlighter".

With the -F option, you can add filters to the token stream, you can
give options in the same way as for -O after a colon (note: there must
not be spaces around the colon).

The -O, -P and -F options can be given multiple times.

With the -S option, print out style definitions for style <style>
for formatter <formatter>. The argument given by -a is formatter
dependent.

The -L option lists lexers, formatters, styles or filters -- set
`which` to the thing you want to list (e.g. "styles"), or omit it to
list everything.

The -N option guesses and prints out a lexer name based solely on
the given filename. It does not take input or highlight anything.
If no specific lexer can be determined "text" is returned.

The -H option prints detailed help for the object <name> of type <type>,
where <type> is one of "lexer", "formatter" or "filter".

The -h option prints this help.
The -V option prints the package version.
4416 次点击
所在节点    Python
26 条回复
scys
2014-11-28 22:26:53 +08:00
这不是error log 这个是帮助信息。
pip list 会不会列出你的包列表?
觉得是你把shell 编译坏了
abccba
2014-11-28 22:32:03 +08:00
@scys 谢谢

pip之类的python程序已经完全没法用了

% pip list
Error: cannot read infile: [Errno 2] No such file or directory: 'list'
~
% pip show
Error: cannot read infile: [Errno 2] No such file or directory: 'show'
scys
2014-11-28 22:33:18 +08:00
下线的服务器就下线,应该被挂了东西
abccba
2014-11-28 22:36:28 +08:00
@scys

pip install xx ## 嗯,输入的就是“xx”,其实这里不论输入xx,还是其它什么,结果都是相同的

程序没法执行,输出都是楼主贴出的那段提示。
abccba
2014-11-28 22:37:39 +08:00
@scys
我自己的笔记本。。。我是菜鸟,不太懂pip/python之类的,只会一点python语法。
“被挂了东西” => 被入侵了?
skybr
2014-11-28 22:43:34 +08:00
你是不是喜欢在全局模式下pip安装东西? 我猜是你安装的类库不向下兼容, 系统的依赖被破坏了。
scys
2014-11-28 22:48:20 +08:00
自己电脑?重新灌次gentoo没法判断你破坏了什么
kidlj
2014-11-28 22:48:22 +08:00
输出的好像是某个包的帮助文档啊,可是竟然搜不出来是什么包。

你切换一下python版本试试:

$ sudo eselect python list
Available Python interpreters:
[1] python2.7 *
[2] python3.3

$ sudo eselect python set 2
kidlj
2014-11-28 22:50:04 +08:00
哈哈,一下想起来,eselect你也是没法用的。在Gentoo下玩坏Python是很要命的呢。
abccba
2014-11-28 22:51:22 +08:00
@skybr
不喜欢绕过portage装东西,不过上次好像是用pip装过啥,可惜现在查.zsh_history看不到了。
有办法吧pip安装的都删掉么,没有用pip安装过非常重要的包,强制删掉应该没问题吧。
abccba
2014-11-28 22:53:56 +08:00
@kidlj
emerge/eselect可以用
感觉好像是pygments的原因,**印象中**前些天用过pip install pygmetns,或者pip install 什么包,现在查不到了。
kidlj
2014-11-28 22:54:03 +08:00
emerge 还能用吗?

至于pip,

$ pip list
$ pip uninstall <package>
abccba
2014-11-28 22:54:24 +08:00
@scys 。。。 请祝我好运!
scys
2014-11-28 22:56:25 +08:00
灌gentoo 不需要吧?要不换arch 好了
abccba
2014-11-28 23:02:06 +08:00
@kidlj

emerge还能用

% pip list
Error: cannot read infile: [Errno 2] No such file or directory: 'list'

强烈推测为“pygmetns”的原因,
我在/usr/bin下把所有带“__requires__ = 'Pygments==1.6'”的程序都试了一下,都是这个错误;
而没有 requires pygments的都没有这个错误。
abccba
2014-11-28 23:03:36 +08:00
@scys
什么叫作 灌 ?搜了一把,还是不理解这个术语啊。。。
timonwong
2014-11-28 23:06:18 +08:00
你说对了,这些错误提示和帮助信息,还真是pygments (pygmentize命令)
scys
2014-11-28 23:09:15 +08:00
@abccba 灌是我习惯语。就是重装意思。
尝试修复下@timonwong似乎找到问题点?
timonwong
2014-11-28 23:09:54 +08:00
abccba
2014-11-28 23:28:32 +08:00
@scys 那个问题和这里的问题,形同神异的样子。 :(

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/150079

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX