llvmlite: Unable to install llvmlite in pip on Apple Silicon Mac (M1)
I’m having problems installing llvmlite from pip on MacOS Big Sur. The installation breaks on this check: clang-9: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11'. I checked with clang --version and I actually have clang 12.0 installed right now, but I think llvmlite uses its own custom clang++ based on version 9. But surely there is a way to get it to compile on Big Sur/M1 hardware? I tried running pip with arch -x86_64 prefix but it didn’t make any difference. I also tried installing ==0.33 to try an older version but got the same error message.
Can anyone help me solve this problem?
[ilya:/opt/homebrew] 1 % pip install --platform macosx_10_9_x86_64 --target=/tmp numba
ERROR: When restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).
[ilya:/opt/homebrew] 1 % pip install llvmlite
Collecting llvmlite
Using cached llvmlite-0.35.0.tar.gz (121 kB)
Building wheels for collected packages: llvmlite
Building wheel for llvmlite (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/setup.py'"'"'; __file__='"'"'/private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-wheel-chloq3u1
cwd: /private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/
Complete output (19 lines):
running bdist_wheel
/usr/local/opt/python@3.9/bin/python3.9 /private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/ffi/build.py
LLVM version... MACOSX_DEPLOYMENT_TARGET=11 clang++ -std=c++11 -stdlib=libc++ -dynamiclib -I/usr/local/Cellar/llvm@9/9.0.1_2/include -std=c++11 -stdlib=libc++ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp object_file.cpp custom_passes.cpp -o libllvmlite.dylib -L/usr/local/Cellar/llvm@9/9.0.1_2/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVMXRay -lLLVMWindowsManifest -lLLVMTextAPI -lLLVMTableGen -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMOrcJIT -lLLVMJITLink -lLLVMObjectYAML -lLLVMMCA -lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMLineEditor -lLLVMLibDriver -lLLVMInterpreter -lLLVMFuzzMutate -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMDlltoolDriver -lLLVMOption -lLLVMDebugInfoGSYM -lLLVMCoverage -lLLVMCoroutines -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Utils -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyInfo -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVDisassembler -lLLVMRISCVCodeGen -lLLVMRISCVAsmParser -lLLVMRISCVDesc -lLLVMRISCVUtils -lLLVMRISCVInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430CodeGen -lLLVMMSP430AsmParser -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFCodeGen -lLLVMBPFAsmParser -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMAArch64AsmParser -lLLVMMCParser -lLLVMAArch64Desc -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMSupport -lLLVMDemangle -lz -lcurses -lm -lxml2
clang-9: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11'
make: *** [all] Error 1
9.0.1
SVML not detected
Traceback (most recent call last):
File "/private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/ffi/build.py", line 191, in <module>
main()
File "/private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/ffi/build.py", line 185, in main
main_posix('osx', '.dylib')
File "/private/var/folders/0p/y9v6h7xd3tgdp8cg8_5649n40000gn/T/pip-install-bulqlmh_/llvmlite_8af07074863e432eb5155a54d00bd44b/ffi/build.py", line 173, in main_posix
subprocess.check_call(['make', '-f', makefile])
File "/usr/local/Cellar/python@3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.osx']' returned non-zero exit status 2.
error: command '/usr/local/opt/python@3.9/bin/python3.9' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for llvmlite
Running setup.py clean for llvmlite
Failed to build llvmlite
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 25
- Comments: 54 (20 by maintainers)
Commits related to this issue
- remove upper limit on Python version As suggested on https://discuss.python.org/t/requires-python-upper-limits/12663 and on https://github.com/numba/llvmlite/issues/693#issuecomment-1011411673 we s... — committed to esc/numba by esc 2 years ago
- Disable Python3 Numba tests also on macOS12 ARM Because it is not possible at the moment to install numba with pip on macOS12 on ARM. https://github.com/numba/llvmlite/issues/693 https://github.com/n... — committed to etejedor/rootspi by etejedor 2 years ago
- Disable Python3 Numba tests also on macOS12 ARM Because it is not possible at the moment to install numba with pip on macOS12 on ARM. https://github.com/numba/llvmlite/issues/693 https://github.com/n... — committed to root-project/rootspi by etejedor 2 years ago
I was able to install llvmlite with pipenv on an m1 with the following steps:
arch -arm64 brew install llvm@11LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_2/bin/llvm-config" arch -arm64 pipenv install llvmliteIt’s important to:
brew install llvmwill get you version 12, and llvmlite specifically calls this out as a compatibility error).arch.LLVM_CONFIGvalue is correct for your system (homebrew has recently changed where it puts things).@thatandromeda 's workaround worked for me but I had to update the config path with
/11.1.0_3/and use my homebrew installed python instead:FWIW: work to officially start supporting the Numba stack on M1 has commenced now and I am actively working on this: https://github.com/numba/llvmlite/pull/813
@texadactyl thank you for commenting on this. I’d like to get this issue into shape, so there are three things I am thinking about:
aarch64platforms like Raspberry-PiThis issue additionally mentions lack of 3.9 support. FWIW: the latest version 0.36.0 now does have 3.9 support!
In essence, I think we ought to clarify which bug/feature this ticket is asking for. How does that sound?
hi, you can use ‘conda install llvmlite’…
For me it worked simply with
pip install llvmliteafter making sure that/opt/homebrew/opt/llvm@11/binis inPATH, but definingLLVM_CONFIGshould also do the trick, like @thatandromeda mentioned. No other options are needed, as far as I can tell, it figures out the architecture correctly.Are there any updates on this?
I’d opt to treat this issue as: “making llvmlite work on M1 silicon”
on Apple/M1:
On Mac M1, the following worked well for me.
FWIW: I will be looking into building binary wheels for the M1 platform .
I would recommend trying a Numba release candidate too, for example 0.55.0rc1 – it should work with the llvmlite RC.
xref: https://github.com/numba/numba/issues/6589#issuecomment-752226780 there’s packages available from conda-forge.
FYI, Requires-Python was not designed or intended to limit Python versions. It was added solely to allow old versions of Python to be nicely dropped. Numba was used as one of the examples of how this is currently not supported correctly when discussing the issue and three possible solutions (see https://discuss.python.org/t/requires-python-upper-limits/12663 ). TL;DR: solution 1 would make it a warning or error to set an upper limit (which is would require the least changes, since the current ecosystem doesn’t handle upper limits correctly), solution 2 would add an error if an upper cap was hit instead of “scrolling back” for older versions with looser/missing upper caps, and solution 3 would be to ignore upper caps. Core devs seemed to be liking solution 1, people writing packages seemed to like solution 2 (which, IMO, might be the worst solution, even though it’s giving people that they think they want). Also see https://iscinumpy.dev/post/bound-version-constraints/.
This is really bad for numba, since it gets an old version, which gets an old version of LLVMLite, which then breaks when compiling, instead of telling the user anything about Python being too new.
In the current system, the best solution is to remove the metadata cap (from both llvmlite and numba) - this will cause the setup.py to be run, and will produce the correct error message. You can also see the workaround SciPy is trying to implement, since they insist on incorrectly setting this metadata item.
This does also show an interesting feature for upper capping, though - in this case, solvers could solve forward for the RC version on Python 3.10, rather than looking back for an older uncapped version. (They don’t do this, and it would be complicated to add, but interesting thing not previously discussed).
Numba 0.53.1 requires llvmlite 0.36 Numba 0.54.0 requires llvmlite 0.37
If you use Numba
masteryou have a Numba0.55.0dev0and need llvmlite0.38.0dev0.(I hope that is correct, please do correct me if I made a mistake.)
Correct. LLVM 12 support for llvmlite will likely arrive in 2022 🤞
Slowly but surely the Anaconda Distribution packages for the M1 silicon are coming out. Hopefully we can start shipping official support for that hardware soon so you won’t have to use hacks anymore to get it installed.
I’ve added this to my list and will revisit when I begin to tackle this issue, thank you!!
No worries, I think that is sufficient for now and I’ll get back to you if anything is missing.
Good, thank you for confirming this. Probably then using
conda+ theconda-forgechannels is a good workaround for folks trying to use llvmlite on apple silicon right now.@esc I just tried but I’m not sure if I did what I was expected. I wonder if you could check.
I’m afraid I’m not familiar with conda related things. I appreciate your help if I should do something.
I just tried conda for the first time and conda-forge of macOS ARM builds. https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/
conda install llvmlitesucceeded installing arm64 version without error…