0

鉴于https://github.com/agronholm/pythonfutures/issues/41,这可能属于“不要这样做”类别- 它是一个专门用于仅在 Python 2 上使用的反向移植库。但奇怪的是,我看到安装它会导致在 Amazon Linux 上特别严重的症状,而在其他地方则不那么明显。测试用例:

$ docker run -it amazonlinux /bin/bash
bash-4.2# yum install -y python36-virtualenv > /dev/null
bash-4.2# virtualenv-3.6 ~/testenv
Using base prefix '/usr'
New python executable in /root/testenv/bin/python3.6
Also creating executable in /root/testenv/bin/python
Installing setuptools, pip, wheel...done.
bash-4.2# source ~/testenv/bin/activate
(testenv) bash-4.2# pip --version
pip 9.0.3 from /root/testenv/local/lib/python3.6/site-packages (python 3.6)
(testenv) bash-4.2# pip install futures
Collecting futures
  Downloading futures-3.1.1.tar.gz
Building wheels for collected packages: futures
  Running setup.py bdist_wheel for futures ... done
  Stored in directory: /root/.cache/pip/wheels/ad/79/48/b32521764d59b16fd1bc0ffd
5862f6d3bf770c7d73ea1fb12a
Successfully built futures
Installing collected packages: futures
Successfully installed futures-3.1.1
(testenv) bash-4.2# pip --version
Traceback (most recent call last):
  File "/root/testenv/bin/pip", line 7, in <module>
    from pip import main
  File "/root/testenv/local/lib/python3.6/site-packages/pip/__init__.py", line 4
5, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/root/testenv/local/lib/python3.6/site-packages/pip/vcs/subversion.py",
line 9, in <module>
    from pip.index import Link
  File "/root/testenv/local/lib/python3.6/site-packages/pip/index.py", line 31,
in <module>
    from pip.wheel import Wheel, wheel_ext
  File "/root/testenv/local/lib/python3.6/site-packages/pip/wheel.py", line 6, i
n <module>
    import compileall
  File "/usr/lib64/python3.6/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/__ini
t__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/_base
.py", line 381
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax

只需在其他 Linux 发行版上的 python 3 上安装 futures 包似乎不会导致 pip 中断,我还无法在 Ubuntu 或 Fedora 上引起相同的症状。amazonlinux 上的 virtualenv 内部发生了什么导致这个问题特别糟糕?如果我通过 pip 而不是从 amazon linux yum 包 python36-virtualenv 安装 virtualenv,问题也不会出现在那里。

4

0 回答 0