0

I'm trying to use pip to install python packages on an RHEL instance but get this error when I try to run any pip command.
Pip did previously work but all of a sudden (not sure what I did) it started to fail like this.

[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: ~]# 

I have tried to reinstall pip which comes up with an error saying the dependency python-setuptools is missing

[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: ~]# 

Trying to install python-setuptools shows the message no package found

[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: ~]# 
3
  • You should copy-paste commands and output into code-blocks, rather than post screenshots, where possible. Not only does that reduce bandwidth, it helps people help you because they can copy what you've got to their own terminals or Google and try it out for themselves. As it is, anyone wanting to reproduce your problem or look up your errors would need to type it out from scratch.
    – cryptarch
    Commented Jan 10, 2019 at 3:45
  • 1
    Good point, changed it.
    – Michael
    Commented Jan 10, 2019 at 4:14
  • The reason why yum is failing is because your RHEL6 system isn’t connected to RHN or RHN Satellite. You aren’t able to pull down updates. You do have EPEL enabled but it is useless without the OS packages.
    – jsbillings
    Commented Jan 12, 2019 at 15:55

1 Answer 1

0

The error seems to be from the use of set literal syntax {':all:'}.

The creation of set by using literal {} has been introduced in Python 3.1 and is backported to 2.7.

As you're using Python 2.6 interpreter, which does not have the syntax (and is EOL-ed a while ago), you're getting the SyntaxError as expected.

One solution would be to upgrade Python version globally, but you need to be absolutely sure as that could very well break important system components.

Another and far better option would be to use a virtual environment for Python interpreter (e.g. virtualenv).

FWIW, 2019 is the last year of support for Python 2.7.

7
  • Thank you that makes perfect sense! The server this is running on is RHEL 6.6 with python 2.6.6! I will try upgrading it to 2.7 and see what happens (not a critical system). Might have to look at upgrading to RHEL 7.X if python2 is soon to be EOL
    – Michael
    Commented Jan 10, 2019 at 8:16
  • @Michael It's 2019; you definitely should start using Python 3 :)
    – heemayl
    Commented Jan 10, 2019 at 10:40
  • I always try python3 first, but that's not always possible with systems that have been running untouched for a while :)
    – Michael
    Commented Jan 10, 2019 at 11:11
  • Don’t upgrade the OS python to 2.7. It is a critical part of RHEL and changing it will prevent the OS from working. Red Hat will continue to support the OS version of python past when the upstream python devs stop supporting it. Ignore anyone who tells you that you need to update the OS python using any means other than through RHEL packages.
    – jsbillings
    Commented Jan 12, 2019 at 15:52
  • @jsbillings I hope you read the bold notice on my answer and also OP's comments.
    – heemayl
    Commented Jan 12, 2019 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .