"AssertionError: Only python 2.7 and later is supported by ptyprocess", when installing pexpect via pip on python 2.6

"AssertionError: Only python 2.7 and later is supported by ptyprocess", when installing pexpect via pip on python 2.6

尝试通过 pip 安装 pexpect 时出现以下错误:

# pip install pexpect
Collecting pexpect
do_ypcall: clnt_call: RPC: Unable to receive; errno = Connection refused
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached pexpect-4.0.tar.gz
Collecting ptyprocess>=0.5 (from pexpect)
  Using cached ptyprocess-0.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-2X4It7/ptyprocess/setup.py", line 10, in <module>
        "Only python 2.7 and later is supported by ptyprocess.")
    AssertionError: Only python 2.7 and later is supported by ptyprocess.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2X4It7/ptyprocess

很明显,下载的 ptyprocess 仅适用于 python 2.7,但 pip 不应下载与已安装的 python 兼容的正确软件包版本版本?

我的系统信息:

pip -V: pip 7.1.2 from /usr/lib/python2.6/site-packages (python 2.6)

python -V: Python 2.6.6

OS: CentOS 6.3

顺便说一句:yum install pexpect 成功安装 pexpect 包

谢谢

AssertionError: Only python 2.7 and later is supported by ptyprocess.

pyexpect 取决于 ptyprocess>=0.5 (https://github.com/pexpect/pexpect/blob/master/setup.py#L66)

您需要先安装一个版本为 ptyprocess 的 >=0.5 但适用于 python 2.6,然后再安装 pyexpect.

edit 看起来你运气不好,0.5 需要 python 2.7 (https://github.com/pexpect/ptyprocess/blob/master/setup.py#L9-L10)。您的系统包已经打补丁以支持 2.6,因此您必须使用它。

yum 将安装 pexpect v2.3.6。

easy_install 或 pip 将从今天开始安装 pexpect v4.0.1。

您可以使用不依赖于 ptyprocess 版本的 pexpect 版本 3.3。

# easy_install pexpect==3.3

# pip install pexpect==3.3