[PYTHON] When architecture not supported comes out with pip (Mac)

Apple announced that it will release a Mac with ARM in June 2020 It hasn't been released yet, but it's actually having an impact. I use pipenv for the python environment, but I encountered an error when building the environment, so I got stuck in that memorandum

environment

macOS Catalina 10.15.7 Pipenv 2020.11.4

error contents

I got an error when installing mysqlclient, but the module I'm installing doesn't seem to have much to do with this issue

$ pipenv install mysqlclient

Hitting this command will spit out a large number of errors and the installation will fail. Looking inside the error,

[pipenv.exceptions.InstallError]:     Complete output (120 lines):
[pipenv.exceptions.InstallError]:     running install
[pipenv.exceptions.InstallError]:     running build
[pipenv.exceptions.InstallError]:     running build_py
[pipenv.exceptions.InstallError]:     creating build
[pipenv.exceptions.InstallError]:     creating build/lib.macosx-10.14.6-x86_64-3.8
[pipenv.exceptions.InstallError]:     creating build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/__init__.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/_exceptions.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/connections.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/converters.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/cursors.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/release.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     copying MySQLdb/times.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     creating build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14.6-x86_64-3.8/MySQLdb/constants
[pipenv.exceptions.InstallError]:     warning: build_py: byte-compiling is disabled, skipping.
[pipenv.exceptions.InstallError]:
[pipenv.exceptions.InstallError]:     running build_ext
[pipenv.exceptions.InstallError]:     building 'MySQLdb._mysql' extension
[pipenv.exceptions.InstallError]:     creating build/temp.macosx-10.14.6-x86_64-3.8
[pipenv.exceptions.InstallError]:     creating build/temp.macosx-10.14.6-x86_64-3.8/MySQLdb
[pipenv.exceptions.InstallError]:     xcrun -sdk macosx clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -I/usr/local/opt/[email protected]/include -Dversion_info=(2,0,1,'final',0) -D__version__=2.0.1  -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.macosx-10.14.6-x86_64-3.8/MySQLdb/_mysql.o
[pipenv.exceptions.InstallError]:     In file included from MySQLdb/_mysql.c:29:
[pipenv.exceptions.InstallError]:     In file included from /usr/local/Cellar/mysql/8.0.22/include/mysql/mysql.h:45:
[pipenv.exceptions.InstallError]:     In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stdint.h:52:
[pipenv.exceptions.InstallError]:     In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
[pipenv.exceptions.InstallError]:     In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:32:
[pipenv.exceptions.InstallError]:     /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
[pipenv.exceptions.InstallError]:     #error Unsupported architecture

And come out. This last # error Unsupported architecture is the miso, which actually specifies the ARM architecture when installing. Therefore, you can specify the current architecture, x86_64.

$ export ARCHFLAGS="-arch x86_64"

Just do this and do pipenv install mysqlclient again

The harmful effects of becoming ARM come from such a place.

Recommended Posts

When architecture not supported comes out with pip (Mac)
When moss with pip install
When the program pip installed on Mac / Marvericks does not work
When I screenfetch with xonsh, python x.x comes out and it's sad
When Anaconda Navigator (Mac) does not start
A workaround when installing pyAudio with pip.
Error when installing a module with Python pip
How to deal with errors when hitting pip ②
Spider not found appears when crawling with Scrapy
When wildcard specification does not work with pylint
I got an error when pip install pandas on Mac, so I dealt with it