Let's say I want to install pybox2d
(but this applies to other packages as well), and I can see on the Anaconda website that this package obviously exists, but it cannot be found when trying to install it on my new Macbook (one of the ones with the new Apple M1 or M2 CPUs). What should I do?
conda search pybox2d -c conda-forge
Loading channels: done
No match found for: pybox2d. Search: *pybox2d*
PackagesNotFoundError: The following packages are not available from current channels:
- pybox2d
Current channels:
- https://conda.anaconda.org/conda-forge/osx-arm64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/osx-arm64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-arm64
- https://repo.anaconda.com/pkgs/r/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.
Note: There are other Stack Overflow questions which relate to this but don't quite answer the question as I have asked it here, so I wanted to make it more direct.
If you look at the linked webpage above (at the time of writing), you can see that osx-arm64
is not listed under the "Installers". However, in the output above we can see that we are only searching in osx-arm64
, and not in osx-64
. The explanation for this is that this package is not built for our new Apple architecture (the new M1 and M2 chips are ARM-based, not Intel-based).
However, it is possible to run programs which were compiled for Apple Intel using some kind of translation called Rosetta. We can have some python environments which are built off of the x86 instruction set.
To do this, just add CONDA_SUBDIR=osx-64
to your env creation. You will also want to configure that environment so that it always installs this type of package. This way, your other environments can still be osx-arm64
by default, and you can just configure an environment as osx-64
only when needed (only when you need an old package that hasn't been cross-compiled to the new architecture).
$ CONDA_SUBDIR=osx-64 conda create -n my_intel_env --file environment.yml
$ conda activate my_intel_env
$ conda config --env --set subdir osx-64
The downside of using the old architecture, as far as I know, is increased startup costs for the program, when the program needs to be translated from one instruction set to another. I'm not sure if this happens only once or more often.
mkl
for now.