Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sunyi00/b527426fbadd560b9664449fde1cdfe9 to your computer and use it in GitHub Desktop.

Select an option

Save sunyi00/b527426fbadd560b9664449fde1cdfe9 to your computer and use it in GitHub Desktop.

Revisions

  1. @MxJ24 MxJ24 created this gist Mar 6, 2021.
    50 changes: 50 additions & 0 deletions Apple M1 Python2 install Django 1.8 envs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    -- Disable SIP (csrutil disable)
    ref: https://github.com/pypa/virtualenv/issues/2023

    -- Run SHELL as x86_64 mode
    arch -x86_64 $SHELL
    ref: https://sspai.com/post/63935

    -- uninstall arm 64 brew (if needed)
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

    -- install x86_64 brew
    https://brew.sh/
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    which brew
    /usr/local/bin/brew -> x86_64
    /opt/homebrew/bin/brew -> arm

    -- uninstall x86_64 mysql (if needed)
    #Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
    brew services stop mysql
    brew uninstall --force mysql
    rm -R /usr/local/var/mysql
    brew install [email protected]
    brew services start [email protected]
    brew link [email protected] --force

    -- uninstall arm mysql (if needed)
    brew uninstall mysql

    -- install x86_64 mysql
    arch -x86_64 brew install [email protected]

    -- install pip (if needed)
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python3 get-pip.py

    -- install python envs
    mkdir -p ~/workspace/envs;
    cd ~/workspace/envs;arch -x86_64 virtualenv -p $(which python) misv2
    cd ~/workspace/envs;source ./misv2/bin/activate;cd ~/workspace/misv2
    arch -x86_64 $(which python) -m pip install -r requirement.txt

    -- x86_64 brew compile MySQL-python driver
    env LDFLAGS="-L$(/usr/local/bin/brew --prefix openssl)/lib" CFLAGS="-I$(/usr/local/bin/brew --prefix openssl)/include"
    LDFLAGS=-L/usr/local/opt/openssl/lib arch -x86_64 $(which python) -m pip install MySQL-python==1.2.5
    ref: https://github.com/PyMySQL/mysqlclient/issues/131

    -- run django
    arch -x86_64 python manage.py runserver