Jan 30, 2021 2 mins

mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)

incompatible architecture incompatible architecture

Hello there, I'm trying to debug my azure orchestrator function locally. I'm using python3 psycopg2 client library to connect with my Postgres DB which is running on Azure. Also I'm using VS code with Azure function extension on my Apple mac book M2. But When I try to run the orchestrator function locally execution is failing with following error messages.

Note: I’m using psycopg2-binary module instead of psycop2


Traceback (most recent call last):
  File "/Users/user/Documents/Projects/Project/Project-data/", line 1, in <module>
    import psycopg2 as pg
  File "/Users/user/Library/Python/3.9/lib/python/site-packages/psycopg2/", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: dlopen(/Users/user/Library/Python/3.9/lib/python/site-packages/psycopg2/, 0x0002): tried: '/Users/user/Library/Python/3.9/lib/python/site-packages/psycopg2/' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/user/Library/Python/3.9/lib/python/site-packages/psycopg2/' (no such file), '/Users/user/Library/Python/3.9/lib/python/site-packages/psycopg2/' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

Why is This Error?

The error message “mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)” typically occurs when there is an attempt to execute or link a binary file on an Apple Silicon (M1) Mac that was built for the x86_64 architecture (Intel), but the system is expecting the arm64 architecture (Apple Silicon).

Here’s a breakdown of the key components of the error

mach-o file: Refers to the executable file format used by macOS and iOS.

incompatible architecture: Indicates that the architecture of the binary file is not compatible with the architecture expected by the system.

(have ‘x86_64’, need ‘arm64’): Specifies the specific architectures involved. In this case, the binary is built for the x86_64 architecture, but the system requires the arm64 architecture.

To address this error, consider the following steps

Recompile for Apple Silicon

If you have access to the source code, recompile the application or library for the arm64 architecture. This can be done using Xcode on an Apple Silicon Mac.

Check for Updates

Ensure that you are using the latest version of the software or library. Developers may release updates with native support for Apple Silicon.

Rosetta 2 Compatibility

If a recompiled version is not available, you can run the application using Rosetta 2, which is a translation layer that allows x86_64 binaries to run on Apple Silicon Macs. You can launch the application through Terminal using:

arch -x86_64 /path/to/application


Alternatively, you can use virtualization software (e.g., Parallels, VMware) to run an x86_64-based virtual machine on your Apple Silicon Mac.

It’s important to note that transitioning to native arm64 support is the preferred approach for optimal performance on Apple Silicon Macs. Using Rosetta 2 or virtualization provides compatibility but may not leverage the full potential of the new architecture.


  • Avatar

    Danielle Carline

    Posted on

    Hello, I also had the same issue. As you can see in the error messages, it is trying to load psycop2 module from your global python path. It seems you don’t have psycopg2-binary installed in that path.

    So, What I suggest is,

      1. Remove existing python virtual env from your project root if exist.
      1. Then create a new python virtual environment in your project root.
      1. Activate the new python virtual env
      1. Run pip install -r requirements.txt
    python3 -m venv .venv  
    source .venv/bin/activate
    pip install -r requirements.txt

Write a comment

You can use the Markdown syntax to format your comment.

  • Tags:
  • python
  • Share: