Problem with pip : it thinks it's a different version

hello,

i’m trying to install some packages on a CentOS 7 system using pip3. both pip and pip3 are installed on the system. pip3 won’t install the packages because for some reason it doesn’t seem to recognise that its version of python is correct.

an example (edited for clarity) :

    $ python3 --version
    Python 3.6.8
    
    $ pip3 --version
    pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
    
    $ pip3 -v install package
    Collecting package
      1 location(s) to search for versions of package:
      * https://pypi.python.org/simple/package/
      Getting page https://pypi.python.org/simple/package/
      Looking up "https://pypi.python.org/simple/package/" in the cache
      Returning cached "301 Moved Permanently" response (ignoring date and etag information)
      Looking up "https://pypi.org/simple/package/" in the cache
      Current age based on date: 429
      Freshness lifetime from max-age: 600
      Freshness lifetime from request max-age: 600
      The response is "fresh", returning cached response
      600 > 429
      Analyzing links from page https://pypi.org/simple/package/
        Skipping link https://files.pythonhosted.org/packages/{very-long-path-here} (from https://pypi.org/simple/package/) (requires-python:>=3.5); it is not compatible with this Python
  ...

so even though pip3 recognises that it’s from python 3.6, it won’t install packages requiring python 3.5 or greater, saying “it is not compatible withi this Python”.

i have also tried python3 -m pip install package , this gives me the same error.
i have also tried python3 -m pip install package -t {path}, where {path} is one of the elements in sys.path, for each element of the path except /usr/local/bin and the zip file.

printing sys.path gives me the following :

['/usr/local/bin', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/usr/local/lib64/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages']

any ideas on how i can resolve this issue ?

failing that, is there a safe way to re-install python 3.6 (and only 3.6) on the system without breaking something else ?

i’m trying to install some packages on a CentOS 7 system using pip3.
both pip and pip3 are installed on the system. pip3 won’t install the
packages because for some reason it doesn’t seem to recognise that its
version of python is correct.

an example (edited for clarity) :

   $ python3 --version
   Python 3.6.8

   $ pip3 --version
   pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

That is a pretty old pip. Contrast to the Python I’m running here:

 pip 22.3 from /Users/cameron/var/venv/3.10.6_1-homebrew/lib/python3.10/site-packages/pip (python 3.10)

I’m presuming this is the system supplied python? The sys.path below
suggests so anyway.

   $ pip3 -v install package
[...]
     Analyzing links from page https://pypi.org/simple/package/
       Skipping link https://files.pythonhosted.org/packages/{very-long-path-here} (from https://pypi.org/simple/package/) (requires-python:>=3.5); it is not compatible with this Python

so even though pip3 recognises that it’s from python 3.6, it won’t install packages requiring python 3.5 or greater, saying “it is not compatible withi this Python”.

There were recent fixes in pip around requirements. May be relevant.

i have also tried python3 -m pip install package

This is the better approach. It’ll be doing the same thing right now,
but at least it ensures that the pip is the one for that python3
install.

any ideas on how i can resolve this issue ?

failing that, is there a safe way to re-install python 3.6 (and only 3.6) on the system without breaking something else ?

I wouldn’t reinstall. See if there are rpm/dnf updates for python3
(and/or the python3 pip package, if that is distinct) with dnf check-update.

You could also make a virtualenv and then upgrade pip inside the
virtualenv:

 $ python3 -m venv ~/venv
 $ ~/venv/bin/python3 -m pip install -U pip
 $ ~/venv/bin/python3 -m pip install package

and see how it goes. When you exec the python3 from inside the
venv/bin it runs with a configuration which uses the venv as the
install area. You can then try updating pip, and then try installing
your problematic package using the updated pip to see if it behaves
better.

If not, the next step would be a distinct separate install of Python
3.6 (or better still, a more recent Python - 3.11 came out the other
day) elsewhere. Nothing prevents you having several installs; just don’t
trash the system vendor suppplied install. Eg install in
/usr/local/python-some-version or /opt/python-some-version or, of
course, ~/python-some-version (install as yourself, avoiding any risk
of putting things in any system controlled area).

Then make a venv from the new version, and then update its pip and
your target package.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like