How to install python library using Rosetta 2 — MAC M1 Apple silicon

Manish Pathak
2 min readAug 31, 2023

Rosetta 2 is a translation layer developed by Apple that allows you to run software compiled for the x86_64 architecture on Apple Silicon (ARM64) Macs. If you have a Python library that doesn’t have native ARM64 support and you want to use it on your ARM64 Mac, you can try using Rosetta 2 to run the x86_64 version of Python and install the library. Here’s how you can do it:

  1. Open Terminal: Launch the Terminal application on your Mac. You can find it in the Applications > Utilities folder, or you can use Spotlight search to find it.
  2. Run Rosetta 2 Python: Use the following command to run the x86_64 version of Python using Rosetta 2:
arch -x86_64 /usr/bin/python3

This will launch the x86_64 version of Python in your Terminal.

3. Install Python Libraries: Once you’re in the x86_64 Python environment, you can use pip to install the Python libraries you need, including Dlib or any other libraries that are not yet available for ARM64. For example:

arch -x86_64 /usr/bin/python3 -m pip install package_name

Replace package_name with the name of the library you want to install.

4. Exit Rosetta Python Environment: After you’ve installed the required libraries, you can exit the x86_64 Python environment by typing exit() and pressing Enter.

Please note that this approach allows you to use the x86_64 version of Python and libraries via Rosetta 2, but it might not provide the best performance or integration with the ARM64 ecosystem. As ARM64 support for various libraries improves, it’s a good idea to transition to native ARM64 versions when available.

--

--