RHELのPip構文エラーが無効です。

RHELのPip構文エラーが無効です。

RHELインスタンスにPythonパッケージをインストールしようとしていますが、pippipコマンドを実行しようとするとこのエラーが発生します。
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期待した結果が得られます。

1つの解決策は、Pythonバージョンをグローバルにアップグレードすることです。重要なシステムコンポーネントが損傷する可能性が高いため、必ず確認してください。

別のより良いオプションは、Pythonインタプリタ用の仮想環境(たとえばvirtualenv)を使用することです。

今後、2019年はPython 2.7をサポートする最後の年です。

おすすめ記事