3

I'm running Centos 5.11. I'm trying to install the python requests package. But pip keeps giving me syntax errors.

pip help returns

[root@32437-201824 bin]# pip help

Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-7.1.2-py2.4.eg/pip/__init__.py", line 211
except PipError as exc:
                 ^
SyntaxError: invalid syntax

which pip returns

[root@32437-201824 bin]# which pip
/usr/bin/pip

[root@32437-201824 bin]# yum list installed | grep pip

returns nothing.

[root@32437-201824 bin]# rpm -qa|grep pip

returns nothing.

[root@32437-201824 bin]# pip install requests

returns the same error as pip help (shown above)

The command

[root@32437-201824 bin]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.szimOy: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
    package epel-release-5-4.noarch is already installed

The command,

[root@32437-201824 bin]# yum install -y python-pip

Returns this after a few lines,

No package python-pip available.
Nothing to do

Another installation method also has syntax errors.

[root@32437-201824 tmp]# python get-pip.py
  File "get-pip.py", line 43
    _b85alphabet = (b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                                      ^
SyntaxError: invalid syntax

The command,

[root@32437-201824 tmp]# python -V
Python 2.4.3

Python runs interactively.

[root@32437-201824 tmp]# python
Python 2.4.3 (#1, Jan  9 2013, 06:47:03) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[1]+  Stopped                 python

So python runs, but pip won't install. I suppose something is out of sync, but what is it?

1

1 Answer 1

0

Don't run pip as root. That puts files in the system site-packages directory that aren't owned by packages. It's a recipe for disaster, as you are already getting a taste of.

Instead, I recommend using the IUS project to get python27 and python27-virtualenv. They are parallel installable with the stock versions, so you don't have to worry about any conflicts. You can then run virtualenv-2.7 to get Python 2.7 virtual environments that are safe to run pip inside of.

1
  • Thanks. Using Sathya's suggestion, I moved to Python 2.7, and the pip install worked as expected. Feb 24, 2016 at 8:23

You must log in to answer this question.

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