尝试在 CentOS6 上安装 virtualenv、requests 或 pex 时,pip install 不起作用。我在 python2.6 和 pip 9.0.1 上。谁能告诉我为什么会这样?
(pex_build)[root@pex pex_build]# pip install virtualenv
输出:
Traceback (most recent call last):
File "/opt/pex_build/bin/pip", line 7, in <module>
from pip._internal import main
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/index.py", line 526
{str(c.version) for c in all_candidates},
^
SyntaxError: invalid syntax
命令:
(pex_build) [root@pex pex_build]# pip install requests pex
输出:
Traceback (most recent call last):
File "/opt/pex_build/bin/pip", line 7, in <module>
from pip._internal import main
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/opt/pex_build/lib/python2.6/site-packages/pip/_internal/index.py", line 526
{str(c.version) for c in all_candidates},
^
SyntaxError: invalid syntax
curl 在尝试获取 get-pip.py 时也会给出类似的错误
命令:
(pex_build) [root@pex pex_build]# curl https://bootstrap.pypa.io/get-pip.py | python
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1602k 100 1602k 0 0 7373k 0 --:--:-- --:--:-- --:--:-- 14.6M
Traceback (most recent call last):
File "<stdin>", line 20636, in <module>
File "<stdin>", line 197, in main
File "<stdin>", line 82, in bootstrap
File "/tmp/tmp5zrn_f/pip.zip/pip/_internal/__init__.py", line 42, in <module>
File "/tmp/tmp5zrn_f/pip.zip/pip/_internal/cmdoptions.py", line 16, in <module>
File "/tmp/tmp5zrn_f/pip.zip/pip/_internal/index.py", line 526
{str(c.version) for c in all_candidates},
^
SyntaxError: invalid syntax