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:
JavaScript
x
2
1
C:UsersmynameDownloadssetuptools-51.1.1>py -2 setup.py install
2
It ended up with a SyntaxError:
JavaScript
1
12
12
1
Traceback (most recent call last):
2
File "setup.py", line 7, in <module>
3
import setuptools
4
File "C:UsersmynameDownloadssetuptools-51.1.1setuptools__init__.py", line 16, in <module>
5
import setuptools.version
6
File "C:UsersmynameDownloadssetuptools-51.1.1setuptoolsversion.py", line 1, in <module>
7
import pkg_resources
8
File "C:UsersmynameDownloadssetuptools-51.1.1pkg_resources__init__.py", line 1365
9
raise SyntaxError(e) from e
10
^
11
SyntaxError: invalid syntax
12
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”:
JavaScript
1
6
1
try:
2
marker = packaging.markers.Marker(text)
3
return marker.evaluate()
4
except packaging.markers.InvalidMarker as e:
5
raise SyntaxError(e) from e
6
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.