突然之间,很多 python 程序都出现了相同的错误 - V2EX
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
abccba

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

  •  
  •   abccba Nov 28, 2014 5025 views
    This topic created in 4184 days ago, the information mentioned may be changed or developed.
    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/query -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.
    Supplement 1    Nov 29, 2014
    推测原因和“pygmetns”有关,
    我在/usr/bin下把所有带“__requires__ = 'Pygments==1.6'”的程序随机抽取部分试了一下,都是这个相同的错误提示;
    而没有 requires pygments的都没有这个错误。
    26 replies    2014-12-19 13:28:19 +08:00
    scys
        1
    scys  
       Nov 28, 2014 via Android   1
    这不是error log 这个是帮助信息。
    pip list 会不会列出你的包列表?
    觉得是你把shell 编译坏了
    abccba
        2
    abccba  
    OP
       Nov 28, 2014
    @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
        3
    scys  
       Nov 28, 2014 via Android
    下线的服务器就下线,应该被挂了东西
    abccba
        4
    abccba  
    OP
       Nov 28, 2014
    @scys

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

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

    你切换一下python版本试试:

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

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

    至于pip,

    $ pip list
    $ pip uninstall <package>
    abccba
        13
    abccba  
    OP
       Nov 28, 2014
    @scys 。。。 请祝我好运!
    scys
        14
    scys  
       Nov 28, 2014 via Android
    灌gentoo 不需要吧?要不换arch 好了
    abccba
        15
    abccba  
    OP
       Nov 28, 2014
    @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
        16
    abccba  
    OP
       Nov 28, 2014
    @scys
    什么叫作 灌 ?搜了一把,还是不理解这个术语啊。。。
    timonwong
        17
    timonwong  
       Nov 28, 2014
    你说对了,这些错误提示和帮助信息,还真是pygments (pygmentize命令)
    scys
        18
    scys  
       Nov 28, 2014 via Android
    @abccba 灌是我习惯语。就是重装意思。
    尝试修复下@timonwong似乎找到问题点?
    abccba
        20
    abccba  
    OP
       Nov 28, 2014
    @scys 那个问题和这里的问题,形同神异的样子。 :(
    skydiver
        21
    skydiver  
       Nov 29, 2014
    @abccba 灌是台湾说法吧。。重灌狂人。。
    abccba
        22
    abccba  
    OP
       Nov 29, 2014
    顶起,看看有木有大牛能帮着解决下。谢谢。
    loading
        23
    loading  
       Nov 29, 2014
    欢迎来 archlinux
    2owe
        24
    2owe  
       Nov 29, 2014 via iPad   1
    推测 Pygments版本过高,可以的话执行pip freeze|grep Pygments 看看是否高于1.6

    如果是这样,应该卸载Pygments,重新安装1.6版本的 Pygments。

    一点点建议:1. Linux python 开发环境 应与系统默认 python 环境区分开 2. 使用pythonenv 管理自己的开发环境 3.系统环境包除非你知道自己在做什么否则别动它,自己的环境多备份以便深度折腾。 :)
    abccba
        25
    abccba  
    OP
       Dec 1, 2014
    @2owe
    谢谢,已经搞定了:是pip和Gentoo的包管理器冲突导致的奇怪错误。emerge -v1 python-exec就好。

    再次谢谢您的建议!
    Owenjia
        26
    Owenjia  
       Dec 19, 2014
    我也遇到了类似的问题,但 pip 可以用,emerge 不能用了~~~
    About     Help     Advertise     Blog     API     FAQ     Solana     1019 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 46ms UTC 22:30 PVG 06:30 LAX 15:30 JFK 18:30
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86