According to your error message from pip, the maximum version of torch that you're allowed to install is 2.2.2. From what I see on PyPI, it seems that 2.2.2 was the last version for which they released wheels for MacOS 10.9+ (see for example that the list of wheels for 2.3.0 does not contain [...]-macosx_10_9[...].whl
, but the list of wheels for 2.2.2 does).
What is your MacOS version? If my understanding is correct, the only version of PyTorch 2.7.1 available for Python 3.9 and MacOS is torch-2.7.1-cp39-none-macosx_11_0_arm64.whl
, so you will need MacOS 11 or newer for it to work.