I need to run some code in Python 2.7.x. I have Python 2.7.16, Python 3.9.6, and both pip and pip3 (which point to the same place) as shown below:
% python --version
Python 2.7.16
% python3 --version
Python 3.9.6
% pip --version
pip 21.1.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
% pip3 --version
pip 21.1.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
The code I am trying to run requires me to run python setup.py build
but this yields the error:
Traceback (most recent call last):
File "setup.py", line 25, in <module>
from Cython.Distutils import build_ext
ImportError: No module named Cython.Distutils
So, installing cython gives me:
% pip install cython
Requirement already satisfied: cython in /usr/local/lib/python3.9/site-packages (0.29.24)
Notice this points to Python 3, not Python 2.7. So I try to run python -m pip install cython
but that yields the following error:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Library/Python/2.7/site-packages/pip-21.0-py2.7.egg/pip/__main__.py", line 21, in <module>
from pip._internal.cli.main import main as _main
File "/Library/Python/2.7/site-packages/pip-21.0-py2.7.egg/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
Not sure what is going on. I recently updated Xcode, so that shouldn't be the issue.