Cannot install Python 3.7 on osx-arm64
Asked Answered
I

3

40

I am trying to create a new environment with Python 3.7 using Conda like:

conda create -n qnn python=3.7 

I got following errors:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - python==3.7

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Why is Python 3.7 apparently unavailable?


System Details

This is on an Apple Silicon (osx-arm64) machine running macOS.

Ido answered 2/12, 2021 at 19:50 Comment(2)
What is your question? Have you used the suggested search option on anaconda.org or conda search python in the command line to see which versions are available?Melodee
support for arm64 is relatively new on conda-forge. I feel the problem is that you requested an older version of python and conda-forge does not support it. Moreover, I think as it is now this is a valid and clear question which does not merit closing.Subside
D
81

No native builds available

Since Python 3.8 had been released for about a year when Apple Silicon hit the market, Python 3.7 builds for osx-arm64 were never part of the regular build matrix for Conda Forge.

Workaround: Emulate

Immediate alternatives for using 3.7 on Apple Silicon systems would be to emulate x86_64 with Rosetta or use a container system, e.g., Docker.

Creating osx-64 environments

Similar to what one does for running win-32 environments on x86_64 machines, one can create osx-64 environments like

## create empty environment
conda create -n py37

## activate
conda activate py37

## use x86_64 architecture channel(s)
conda config --env --set subdir osx-64

## install python, numpy, etc. (add more packages here...)
conda install python=3.7 numpy

⚠️ Important Note: Be sure to always activate this environment before installing packages. Otherwise, the default CONDA_SUBDIR value (osx-arm64) may be active and could result in mixing architectures in the same environment.

Note that MacOS will automatically recognize the architecture and run through Rosetta (once installed) - one need not do anything special.

YAML

With a YAML environment definition, one can use the CONDA_SUBDIR environment variable to temporarily set the platform while creating the environment. Again, one still should set the environment-specific subdir option immediately after creation.

## create environment from YAML
CONDA_SUBDIR=osx-64 conda env create -n py37 -f py37.yaml

## activate
conda activate py37

## use x86_64 architecture channel(s)
conda config --env --set subdir osx-64

Requesting native build

Longer term, you could try requesting that the python-feedstock include a 3.7 build for osx-arm64. However, 3.7.12 (Sept. 2021) was technically the final feature release, and it has now entered the maintenance-only phase (see PEP 537). Also, other packages that build Python-version-specific variants would not be built for osx-arm64, so even if one had python=3.7, the packages wouldn't be there (at least not through Conda). Basically, I wouldn't bet on anyone taking this up.

Dacron answered 3/12, 2021 at 19:51 Comment(6)
Thanks! It worked! I used conda config --env --set subdir osx-64 before conda create -n demo python=3.7.Fowling
@Fowling that means subdir was set for another environment - that is not correct. It must be set for the intended target environment. You should unset it in the original environment it was set in.Dacron
But why it could work? On the other hand, after the command conda config --env --set subdir osx-64, python 3.7 shows in conda search python list. I thought this means python3.7 is available for the environment?Fowling
@Fowling that sets the subdir for the current environment, and Conda still uses that configuration setting as long as it is active, despite running conda create for a new environment. The next time you try using conda install in the environment, Conda will try to installing everything as osx-64, whereas in the new environment it will default back to osx-arm64.Dacron
This worked, but a critical step is to make sure you've installed Rosetta 2, especially before attempting to run conda install .... You can do that with softwareupdate --install-rosetta support.apple.com/en-gb/HT211861Jumbo
conda config --env --set subdir osx-arm64 in case you need to switch back to ARM architecture.Margartmargate
H
12

Not sure if this is the best strategy, but running

CONDA_SUBDIR=osx-64 conda

worked for my use case.

Heptad answered 8/4, 2022 at 17:24 Comment(2)
Yes, that is the "emulate x86_64" option.Dacron
🐐 solution frrApposition
A
-1

At this point we cannot actually install "faiss-gpu" in Mac OS with Silicon chips. This is because "faiss-gpu" is currently supported only with the below python versions, and the minimum python version needed to run for Mac OS with Silicon chip is python 3.8 as for now

Python :: 2.7
Python :: 3.5
Python :: 3.6
Python :: 3.7

This should help :)

Agnew answered 27/1 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.