Pip cannot install some Python packages due to missing platform tag in M1 Mac

2024/11/15 21:57:56

Lately I have been facing issues installing packages through pip.

For e.g. when I try to install the torch package, it fails with the below error

> arch
arm64
> python --version
3.10.12
❯ pip --version                                                         
pip 23.2.1 from /Users/vinayvaddiparthi/repos/makemore/.venv/lib/python3.10/site-packages/pip (python 3.10)
> python -m venv .venv
> source .venv/bin/activate
> pip install torch                                                       
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

Running it in the verbose mode, pip install -vv torch, shows that pip skips all available wheels since none of have system compatible tags. For e.g.

  Skipping link: none of the wheel's tags (cp310-none-macosx_10_9_x86_64) are compatible (run pip debug --verbose to show compatible tags): https://files.pythonhosted.org/packages/2e/27/5c912ccc490ec78585cd463198e80be27b53db77f02e7398b41305606399/torch-2.0.1-cp310-none-macosx_10_9_x86_64.whl (from https://pypi.org/simple/torch/) (requires-python:>=3.8.0)Skipping link: none of the wheel's tags (cp310-none-macosx_11_0_arm64) are compatible (run pip debug --verbose to show compatible tags): https://files.pythonhosted.org/packages/5a/77/778954c0aad4f7901a1ba02a129bca7467c64a19079108e6b1d6ce8ae575/torch-2.0.1-cp310-none-macosx_11_0_arm64.whl (from https://pypi.org/simple/torch/) (requires-python:>=3.8.0)

Similar logs appear for all versions of torch

Checking pip debug --verbose shows the following

❯ pip debug verbose | grep -i -E "macosx|cp310"                            
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.cp310-cp310-macosx_10_16_arm64cp310-cp310-macosx_10_16_universal2cp310-cp310-macosx_10_15_arm64cp310-cp310-macosx_10_15_universal2cp310-cp310-macosx_10_14_arm64cp310-cp310-macosx_10_14_universal2cp310-cp310-macosx_10_13_arm64cp310-cp310-macosx_10_13_universal2cp310-cp310-macosx_10_12_arm64cp310-cp310-macosx_10_12_universal2

I can see that macosx_11_0_arm64 tag is missing here which I believe is why pip is not able to install the wheel for that tag even though it is available. And I have no idea what makes it appear in that list.

I use pyenv for managing the Python environments and I'm not sure if that is causing any issue here.

MacOS details:

❯ sw_vers                                                                  
ProductName:        macOS
ProductVersion:     13.5
BuildVersion:       22G74

Please let me know if you need any more details and thanks for checking.

Answer

Someone answered this question for me on this GitHub issue.

Apparently, it is an issue in Python built with old macOS SDK. There is a workaround available for this but it hasn't landed in pip yet.

So for now, it can be solved manually like this:

SYSTEM_VERSION_COMPAT=0 pip install torch
https://en.xdnf.cn/q/120403.html

Related Q&A

find (i,j) location of closest (long,lat) values in a 2D array [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 9…

an error occured to add picture in python

I am new in python and I am using python 3.5 version. I want to add photo to python, and heres the code I wrote:from tkinter import * win=Tk() win.title("Python Image")canvas=Canvas(win,width…

Implementing stack in python by using lists as stacks [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Addition function in Python is not working as expected

I tried to create a function using which I want to do mathematical operations like (Addition and Multiplication), I could able to prompt the values and when I insert the values result is not returning …

Probability Distribution Function Python

I have a set of raw data and I have to identify the distribution of that data. What is the easiest way to plot a probability distribution function? I have tried fitting it in normal distribution. But …

how to convert a np array of lists to a np array

latest updated: >>> a = np.array(["0,1", "2,3", "4,5"]) >>> a array([0,1, 2,3, 4,5], dtype=|S3) >>> b = np.core.defchararray.split(a, sep=,) >…

Regex stemmer code explanation

Can someone please explain what does this code do?def stemmer(word):[(stem,end)] = re.findall(^(.*ss|.*?)(s)?$,word)return stem

Scraping data from a dynamic web database with Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 9…

Python representation of floating point numbers [duplicate]

This question already has answers here:Floating Point Limitations [duplicate](3 answers)Closed 10 years ago.I spent an hour today trying to figure out whyreturn abs(val-desired) <= 0.1was occasional…

How to grep only duplicate key:value pair in python dictionary?

I have following python dictionary.a={name:test,age:26,place:world,name:test1}How to grep only duplicate key:value pair from the above?Output should be: "name: test and name:test1"