How to create an x64 (Intel) conda environment on your Apple Silicon Mac (ARM) conda install
I came across some conda packages that didn’t work properly on my M1 Mac (Apple Silicon – ARM processor) the other day. They installed fine, but gave segmentation faults when run. So, I wanted to run the x64 (Intel) versions of these packages instead.
I haven’t actually needed to do this since I got a M1 Mac (a testament to the quality and range of Arm conda packages available these days through conda-forge), so I wasn’t sure how to do it.
A bit of Googling and experimenting led to this nice simple set of instructions. The upshot of this is you don’t need to install another version of Anaconda/miniconda/etc – you can just create a x64 environment in your existing conda install.
So:
- Run
CONDA_SUBDIR=osx-64 conda create -n your_environment_name python
This is a standard command to create a conda environment, but with
CONDA_SUBDIR=osx-64
prepended to the command. This sets theCONDA_SUBDIR
environment variable, and tells conda to use packages in theosx-64
subdirectory of the package server, rather than the standardosx-arm64
(M1 Mac) subdirectory. This is what gets you the x64 packages. - When this command finishes, you will have a new x64 conda environment. You can then activate it with
conda activate your_environment_name
- Now we need to tell conda to always use this
CONDA_SUBDIR
setting when using this environment, otherwise any future installs in this environment will use the defaultCONDA_SUBDIR
and things will get very confused. We can do this by setting a conda environment config setting to tell conda to set a specific environment variable when you activate the environment. Do this by running:conda env config vars set CONDA_SUBDIR=osx-64
- The output of that command will warn you to deactivate and reactivate the environment, so do this
conda deactivate conda activate your_environment_name
- That’s it! You now have a x64 environment which you can install packages in using standard
conda install
commands.
If you found this post useful, please consider buying me a coffee.
This post originally appeared on Robin's Blog.
Categorised as: Computing, How To, Programming, Python
Leave a Reply