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:UsersmynameDownloadssetuptools-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:UsersmynameDownloadssetuptools-51.1.1setuptools__init__.py", line 16, in <module> import setuptools.version File "C:UsersmynameDownloadssetuptools-51.1.1setuptoolsversion.py", line 1, in <module> import pkg_resources File "C:UsersmynameDownloadssetuptools-51.1.1pkg_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
Advertisement
Answer
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.