4

I needed to install Setuptools for a project I was doing, and I had to download Setuptools through a .tar file (don't ask), but when ran the command I needed to use to install it:

C:\Users\myname\Downloads\setuptools-51.1.1>py -2 setup.py install

It ended up with a SyntaxError:

    Traceback (most recent call last):
      File "setup.py", line 7, in <module>
        import setuptools
      File "C:\Users\myname\Downloads\setuptools-51.1.1\setuptools\__init__.py", line 16, in <module>
        import setuptools.version
      File "C:\Users\myname\Downloads\setuptools-51.1.1\setuptools\version.py", line 1, in <module>
        import pkg_resources
      File "C:\Users\myname\Downloads\setuptools-51.1.1\pkg_resources\__init__.py", line 1365
        raise SyntaxError(e) from e
                                ^
    SyntaxError: invalid syntax

I'm using Python 2.7.

Why is it showing the error, and how can I fix it?

Edit:

When I looked into the __init__.py file, I found that there was something called an "invalid marker":

    try:
        marker = packaging.markers.Marker(text)
        return marker.evaluate()
    except packaging.markers.InvalidMarker as e:
        raise SyntaxError(e) from e
6
  • 1
    That's python3 code. Why do you have to install from a .tar file and not through pip? Commented Dec 29, 2020 at 23:56
  • 1
    Don't use Python 2.7 Commented Dec 30, 2020 at 0:00
  • @SuperStormer If I use pip, I have to use py -2 pip install setuptools because I installed python 3 before python 2. When I run that command, it throws this error: "C:\Python27\python.exe: can't open file 'pip': [Errno 2] No such file or directory" Commented Dec 30, 2020 at 0:07
  • py -2 -m pip install setuptools Commented Dec 30, 2020 at 0:08
  • @zabop The project I'm using setuptools for has python 2 syntax Commented Dec 30, 2020 at 0:08

1 Answer 1

4

The last version of setuptools to support Python 2.7 was 44.1.1 (Jan 2020). See the changelog.

Upgrade your Python version in order to use setuptools 51.1.1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.