RHEL 中的 Pip 语法错误无效

RHEL 中的 Pip 语法错误无效

我尝试pip在 RHEL 实例上安装 python 软件包,但当我尝试运行任何 pip 命令时出现此错误。
皮普以前确实工作过,但突然之间(不知道我做了什么)它开始像这样失败。

[root@universe: ~]# pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==18.1', 'console_scripts', 'pip')()
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 378, in load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2566, in load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2260, in load
  File "/usr/lib/python2.6/site-packages/pip-18.1-py2.6.egg/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python2.6/site-packages/pip-18.1-py2.6.egg/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python2.6/site-packages/pip-18.1-py2.6.egg/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python2.6/site-packages/pip-18.1-py2.6.egg/pip/_internal/cli/cmdoptions.py", line 75
    binary_only = FormatControl(set(), {':all:'})
                                               ^
SyntaxError: invalid syntax
[root@universe: ~]# 

我尝试重新安装 pip,但出现错误,提示python-setuptools缺少依赖项

[root@universe: ~]# yum install python-pip
Loaded plugins: product-id, rhnplugin, security, subscription-manager
There was an error communicating with RHN.
RHN Satellite or RHN Classic support will be disabled.

Error Message:
   Please run rhn_register as root on this client
Error Class Code: 9
Error Class Info: Invalid System Credentials.
Explanation: 
     An error has occurred while processing your request. If this problem
     persists please enter a bug report at bugzilla.redhat.com.
     If you choose to submit the bug report, please be sure to include
     details of what you were trying to do when this error occurred and
     details on how to reproduce this problem.

Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-pip.noarch 0:7.1.0-1.el6 will be installed
--> Processing Dependency: python-setuptools for package: python-pip-7.1.0-1.el6.noarch
--> Finished Dependency Resolution
Error: Package: python-pip-7.1.0-1.el6.noarch (epel)
           Requires: python-setuptools
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@universe: ~]# 

尝试安装python-setuptools显示消息未找到包

[root@universe: ~]# yum install python-setuptools
Loaded plugins: product-id, rhnplugin, security, subscription-manager
There was an error communicating with RHN.
RHN Satellite or RHN Classic support will be disabled.

Error Message:
   Please run rhn_register as root on this client
Error Class Code: 9
Error Class Info: Invalid System Credentials.
Explanation: 
     An error has occurred while processing your request. If this problem
     persists please enter a bug report at bugzilla.redhat.com.
     If you choose to submit the bug report, please be sure to include
     details of what you were trying to do when this error occurred and
     details on how to reproduce this problem.

Setting up Install Process
No package python-setuptools available.
Error: Nothing to do
[root@universe: ~]# 

答案1

该错误似乎是由于使用set文字语法造成的{':all:'}

set通过使用文字的创建{}已经在 Python 3.1 中引入并向后移植到 2.7

当您使用 Python 2.6 解释器时,它没有语法(并且不久前已停产),因此您将得到SyntaxError预期的结果。

一种解决方案是全局升级 Python 版本,但是您需要绝对确定,因为这很可能会损坏重要的系统组件

另一个更好的选择是使用 Python 解释器的虚拟环境(例如virtualenv)。

FWIW,2019 年是支持 Python 2.7 的最后一年

相关内容