V2EX = way to explore
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
V2EX  ›  Python

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

  •  
  •   abccba · 2014-11-28 22:19:08 +08:00 · 4384 次点击
    这是一个创建于 3444 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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.
    第 1 条附言  ·  2014-11-29 07:15:59 +08:00
    推测原因和“pygmetns”有关,
    我在/usr/bin下把所有带“__requires__ = 'Pygments==1.6'”的程序随机抽取部分试了一下,都是这个相同的错误提示;
    而没有 requires pygments的都没有这个错误。
    26 条回复    2014-12-19 13:28:19 +08:00
    scys
        1
    scys  
       2014-11-28 22:26:53 +08:00 via Android   ❤️ 1
    这不是error log 这个是帮助信息。
    pip list 会不会列出你的包列表?
    觉得是你把shell 编译坏了
    abccba
        2
    abccba  
    OP
       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
        3
    scys  
       2014-11-28 22:33:18 +08:00 via Android
    下线的服务器就下线,应该被挂了东西
    abccba
        4
    abccba  
    OP
       2014-11-28 22:36:28 +08:00
    @scys

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

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

    你切换一下python版本试试:

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

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

    至于pip,

    $ pip list
    $ pip uninstall <package>
    abccba
        13
    abccba  
    OP
       2014-11-28 22:54:24 +08:00
    @scys 。。。 请祝我好运!
    scys
        14
    scys  
       2014-11-28 22:56:25 +08:00 via Android
    灌gentoo 不需要吧?要不换arch 好了
    abccba
        15
    abccba  
    OP
       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
        16
    abccba  
    OP
       2014-11-28 23:03:36 +08:00
    @scys
    什么叫作 灌 ?搜了一把,还是不理解这个术语啊。。。
    timonwong
        17
    timonwong  
       2014-11-28 23:06:18 +08:00
    你说对了,这些错误提示和帮助信息,还真是pygments (pygmentize命令)
    scys
        18
    scys  
       2014-11-28 23:09:15 +08:00 via Android
    @abccba 灌是我习惯语。就是重装意思。
    尝试修复下@timonwong似乎找到问题点?
    abccba
        20
    abccba  
    OP
       2014-11-28 23:28:32 +08:00
    @scys 那个问题和这里的问题,形同神异的样子。 :(
    skydiver
        21
    skydiver  
       2014-11-29 00:41:45 +08:00
    @abccba 灌是台湾说法吧。。重灌狂人。。
    abccba
        22
    abccba  
    OP
       2014-11-29 08:05:53 +08:00
    顶起,看看有木有大牛能帮着解决下。谢谢。
    loading
        23
    loading  
       2014-11-29 09:45:24 +08:00
    欢迎来 archlinux
    2owe
        24
    2owe  
       2014-11-29 16:43:37 +08:00 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
       2014-12-01 07:33:54 +08:00
    @2owe
    谢谢,已经搞定了:是pip和Gentoo的包管理器冲突导致的奇怪错误。emerge -v1 python-exec就好。

    再次谢谢您的建议!
    Owenjia
        26
    Owenjia  
       2014-12-19 13:28:19 +08:00
    我也遇到了类似的问题,但 pip 可以用,emerge 不能用了~~~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   789 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:59 · PVG 04:59 · LAX 13:59 · JFK 16:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.