Skip to content

Instantly share code, notes, and snippets.

@sharavsambuu
Last active July 31, 2022 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharavsambuu/2a65fad7b1cde29478a478bdb6e200bc to your computer and use it in GitHub Desktop.
Save sharavsambuu/2a65fad7b1cde29478a478bdb6e200bc to your computer and use it in GitHub Desktop.
Python3 on Mac M1

Visit the following links first, u'll get some ideas

.zprofile

    iarch_name="$(uname -m)"
    if [ "${arch_name}" = "x86_64" ]; then
        if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then
            echo "Running on Rosetta 2"
        else
            echo "Running on native Intel"
        fi
        eval "$(arch -x86_64 /usr/local/Homebrew/bin/brew shellenv)"
        alias ibrew='arch -x86_64 /usr/local/Homebrew/bin/brew'
    elif [ "${arch_name}" = "arm64" ]; then
        echo "Running on ARM"
        eval "$(/opt/homebrew/bin/brew shellenv)"
    else
        echo "Unknown architecture: ${arch_name}"
    fi
    

Run with Rosetta 2 mode

After enabling Rosetta 2 to your terminal, ibrew command can be used to install dependecies like PyQT@5 etc... should be good to go...

Regular worfklows would be like if Rosetta 2 enabled. It is same with ARM64

python3 -m pip install virtualenv
python3 -m virtualenv -p python3 env 
source env/bin/activate
(env) pip install --upgrade pip
(env) pip install -r requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment