1

Why did this error happen? Does this mean pip can't upgrade from 8.1.2?

$ pip install pip --upgrade
Collecting pip
  Downloading https://files.pythonhosted.org/packages/33/c9/e2164122d365d8f823213a53970fa3005eb16218edcfc56ca24cb6deba2b/pip-22.0.4.tar.gz (2.1MB)
    100% |████████████████████████████████| 2.1MB 285kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-rvCiCl/pip/setup.py", line 7
        def read(rel_path: str) -> str:
                         ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rvCiCl/pip/
You are using pip version 8.1.2, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I discount the comments that try to say your pip is 6 years old. It has to be able to upgrade its own package from version 8.1.2 to the stable one, right?

Edit:

OMG I feel like a rookie. My python version was 2.7. ok Throw the tomatoes at me now.

Im leaving this up as a lesson to me.

Peter Moore
  • 1,632
  • 1
  • 17
  • 31
  • It seems pip cannot handle the type annotation in the function. I doubt that was around when pip 8 was released ... do you know why you have such an outdated version of pip? – patrick Mar 22 '22 at 03:40
  • 5
    It looks like your version of python is quite old. Type annotations were added in 3.5 around 6 years ago and your version appears to lack support for them. – jordanm Mar 22 '22 at 03:43
  • What version of python do you have? – teplandr Mar 22 '22 at 03:43
  • it should not matter. pip should always work. And this is because our company has Centos 7 – Peter Moore Mar 22 '22 at 03:43
  • 1
    @PeterMoore It does matter, pip not only downloads the library but precompiles it so it must run the library files. – eyllanesc Mar 22 '22 at 03:45
  • 2
    @PeterMoore You have pip 8.1.2 and you want to update it to 22.0.4 which is a sudden change so many things will break, you can't update to the latest version of pip but you can update to a newer one than you have, try with: `pip install pip==9.0.0` and so try a newer pip until it fails. – eyllanesc Mar 22 '22 at 03:50
  • 1
    What is the output of `pip -V`? Is it part of Python <3.5? `pip` has explicitly dropped support for older Python versions, so if your `pip` is bundled with an old Python version that does not support type annotations, then it's expected to cause problems like this. – Gino Mempin Mar 22 '22 at 04:00
  • The syntax error at the type annotation would seem to indicate that your version of python doesn't support type annotations. – Pranav Hosangadi Mar 22 '22 at 04:03

1 Answers1

1

Try to execute the following commands to get rid of this issue

pip install --upgrade setuptools --user python
pip install --upgrade pip
eyllanesc
  • 235,170
  • 19
  • 170
  • 241