Skip to content

Instantly share code, notes, and snippets.

@MxJ24
Created March 6, 2021 03:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save MxJ24/e1386c9012f533cfbedfed5114da3e60 to your computer and use it in GitHub Desktop.
Save MxJ24/e1386c9012f533cfbedfed5114da3e60 to your computer and use it in GitHub Desktop.
-- 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 mysql@5.7
brew services start mysql@5.7
brew link mysql@5.7 --force
-- uninstall arm mysql (if needed)
brew uninstall mysql
-- install x86_64 mysql
arch -x86_64 brew install mysql@5.7
-- 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
@m-ketan
Copy link

m-ketan commented May 30, 2021

Thanks for this gist. One suggestion though, instead of using arch -x86_64 one can simply run the bash in Rosetta.

@bugpowder
Copy link

bugpowder commented May 31, 2021

One suggestion though, instead of using arch -x86_64 one can simply run the bash in Rosetta.

That's what arch -x86_64 does. Perhaps you meant "run the bash in a Rosetta (intel) instance of the Terminal"?

@hzbd
Copy link

hzbd commented Jun 20, 2021

https://stackoverflow.com/questions/63975881/cant-install-mysqlclient-on-mac/68052339#68052339

Solve the problem that the underlying system platform does not support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment