0

we tried to installe pip on rhel machine - rhel 7.6 version ( we have python 2.7 )

as the following

ls
AUTHORS.txt  build  dist  docs  LICENSE.txt  MANIFEST.in  NEWS.rst  PKG-INFO  pyproject.toml  README.rst  setup.cfg  setup.py  src


python setup.py install
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
  warnings.warn(msg)
Traceback (most recent call last):
  File "setup.py", line 87, in <module>
    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
  File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__
    _Distribution.__init__(self,attrs)
  File "/usr/lib64/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_options
    ep.load()(self, ep.name, value)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2453, in resolve
    raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'check_specifier'

we can see that installing is complain about

 python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',

so we looked on setup.py

and we marked the following line - python_requires

entry_points={
    "console_scripts": [
        "pip=pip._internal.cli.main:main",
        "pip{}=pip._internal.cli.main:main".format(sys.version_info[0]),
        "pip{}.{}=pip._internal.cli.main:main".format(
            *sys.version_info[:2]
        ),
    ],
},

zip_safe=False,
#python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', )

then we run again

installation is now better and we can see the pip is installed as

 which pip
/usr/bin/pip

but last lines are:

Traceback (most recent call last):
  File "setup.py", line 86, in <module>
    zip_safe=False,
  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/site-packages/setuptools/command/install.py", line 73, in run
    self.do_egg_install()
  File "/usr/lib/python2.7/site-packages/setuptools/command/install.py", line 101, in do_egg_install
    cmd.run()
  File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 380, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 604, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 655, in install_item
    self.process_distribution(spec, dist, deps)
  File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 701, in process_distribution
    distreq.project_name, distreq.specs, requirement.extras
TypeError: __init__() takes exactly 2 arguments (4 given)

so after re-run again the python setup.py install , installation succeeded without errors

example of last lines:

Extracting pip-20.1.1-py2.7.egg to /usr/lib/python2.7/site-packages
pip 20.1.1 is already the active version in easy-install.pth
Installing pip script to /usr/bin
Installing pip2.7 script to /usr/bin
Installing pip2 script to /usr/bin

Installed /usr/lib/python2.7/site-packages/pip-20.1.1-py2.7.egg
Processing dependencies for pip==20.1.1
Finished processing dependencies for pip==20.1.1

so the workaround here was the following

marked the line as

#    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',

and run the following twice

 python setup.py install

but this workaround maybe works but it is ugly

any suggestion how to fix the pip installation ?

reference - Using python_requires to require Python 2.7 or 3.2+

jessica
  • 2,426
  • 24
  • 66
  • Why don't you just install it using `yum` ? try `sudo yum install python2-pip`. – Z4-tier Oct 11 '20 at 15:30
  • the reason that we not use yum , is because of many dependencies that are required so more simple is with python sertup.py install ( BTW we are installing only off-line) – jessica Oct 11 '20 at 15:31
  • anyway the latest version from yum is 8.x , and this isn very old version – jessica Oct 11 '20 at 16:45
  • You are going to be a lot happier in the long run if you install a version that is marked as compatible with the version of python that you're planning to use, and is the one recommended by the maintainers of the OS where it will be installed. In the case of Python2 on RHEL, that is pip 8.x. It's kind of ironic that you'd worry about 8.x being old and at the same time trying to install python2 (BTW, 8.x is not that old... they changed the versioning scheme in 2018 to prefix the YEAR, which is why it jumped to version 18.x in 2018, 19.x in 2019....) – Z4-tier Oct 11 '20 at 18:33

0 Answers0