I recently upgraded my Macbook to the latest version and installed the latest version of Python.
I tried installing PyTorch using:
pip install torch
but it fails with the error message:
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch
I upgraded the pip version to the latest, tried again, and encountered the same error.
At this point, I had no other choice than to search GitHub issues for a similar problem, and luckily I found some, but the recommended solution was to install the latest pip. It was marked as resolved, citing the last updated version of pip as a fix.
That’s when it hit me! How about I get the wheel and install it directly.
I did just that. I downloaded the wheel file “torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl”, run pip install and boom!
Guess who said hello?
It was another error message! Yikes.
ERROR: torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl is not a supported wheel on this platform.
After clenching my fist for about 30 seconds, it hit me again! What exactly is the PyTorch wheel, and why is the filename so specific?
I did some digging and got my answers.
How to Install PyTorch on any MacOSX Version with Latest Python Version
At the time of writing this post, the latest Macosx version is 11.1, the Python version is 3.10.1, and the PyTorch version is 1.10.1.
-
Step One: Download the current stable PyTorch wheel
How to Download the current stable PyTorch wheel
You can get it from pytorch or pypi. For MacOSX with Arm Architecture, look for a file that ends witharm64.whl whereas MacOSX with Intel is x86_64.whl.
I am using an Intel Architecture, so the PyTorch wheel I downloaded at the time of writing this post is:
torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl
PyTorch wheel. -
Step Two: Update the python version on the PyTorch wheel filename
How to Update the python version on the PyTorch wheel
Firstly, confirm that the python version on the filename does not already match the one you are using.
To do this, look for the part with -cpXX-. Mine is cp39. The 39 means python 3.9.
If it matches, you can skip this step. Otherwise, change the version to the one that matches yours.
Mine is python version 3.10. So, cp39 becomes cp310.
-
Step Three: Update the MacOSX version on the PyTorch wheel filename
How to Update the MacOSX version on the PyTorch wheel
Confirm that the MacOSX version on the filename does not already match the one installed on your computer.
To do this, look for the part with -macosx_X_X. Mine is -macosx_10_9. This part indicates that the PyTorch wheel is for MacOSX (version 10.9) Mavericks.
If it matches, you can skip this step. Otherwise, change the version to the one that matches yours.
Mine is macos version11.1 so macosx_10_9 becomes macosx_11_1.
If you updated both the python version and macOS version of the PyTorch wheel, the final filename looks like this:
torch-1.10.1-cp310-none-macosx_11_0_x86_64.whl
Updated python wheel. -
Install the Updated PyTorch Wheel
How to Install a Downloaded PyTorch Wheel
Run
pip
, but this time, use the location of the filename of the PyTorch wheel we updated:For instance, if it is in downloads directory, run
pip install /Users/Macsika/Downloads/torch-1.10.1-cp310-none-macosx_11_0_x86_64.whl
Install updated wheel. It should install now with no errors and the success message:
Processing ./torch-1.10.1-cp310-none-macosx_11_0_x86_64.whl Collecting typing-extensions Using cached typing_extensions-4.0.1-py3-none-any.whl (22 kB) Installing collected packages: typing-extensions, torch Successfully installed torch-1.10.1 typing-extensions-4.0.1
Successful PyTorch installation message.. There you go. Hack away!