cvxgrp / pymde

Minimum-distortion embedding with PyTorch
https://pymde.org
Apache License 2.0
526 stars 27 forks source link

Could not find a `llvm-config` binary on Mac M1 #49

Open eleonoravercesi opened 2 years ago

eleonoravercesi commented 2 years ago

Hi, I am trying to install pymde on a MacBook Air with an M1 chip. I have tried both in a virtual environment and globally.

System Version: macOS 12.0.1
Kernel Version: Darwin 21.1.0
/usr/bin/python3 --version
Python 3.8.2

However, I am always facing the same issue.

   ERROR: Command errored out with exit status 1:
     command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/setup.py'"'"'; __file__='"'"'/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-record-veev5qpz/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/eleonoravercesi/Library/Python/3.8/include/python3.8/llvmlite
         cwd: /private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/
    Complete output (14 lines):
    running install
    running build
    got version from file /private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/llvmlite/_version.py {'version': '0.37.0', 'full': 'd77dc1bcdb5af040c549f4d1ceeb4db7c8d08718'}
    running build_ext
    /Library/Developer/CommandLineTools/usr/bin/python3 /private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/ffi/build.py
    LLVM version... Traceback (most recent call last):
      File "/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/ffi/build.py", line 220, in <module>
        main()
      File "/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/ffi/build.py", line 214, in main
        main_posix('osx', '.dylib')
      File "/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/ffi/build.py", line 134, in main_posix
        raise RuntimeError(msg) from None
    RuntimeError: Could not find a `llvm-config` binary. There are a number of reasons this could occur, please see: https://llvmlite.readthedocs.io/en/latest/admin-guide/install.html#using-pip for help.
    error: command '/Library/Developer/CommandLineTools/usr/bin/python3' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/setup.py'"'"'; __file__='"'"'/private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-install-h05etips/llvmlite_698138ee5d98423b8959abdddb1d07cd/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/y_/5kkrlhbj2v1bch8snxxws28c0000gn/T/pip-record-veev5qpz/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/eleonoravercesi/Library/Python/3.8/include/python3.8/llvmlite Check the logs for full command output.

Thank you!

eleonoravercesi commented 2 years ago

After a little search, I have solved my issue with the following steps.

  1. Instead of using Mac python3 (/usr/bin/python3), I have started using brew python3 (/opt/homebrew/bin/python3).
  2. I have installed llvm@11 using brew
    brew install llvm@11
  3. Then, I have manually installed llvmlite by specifying the llvm-config path (found on GitHub):
    LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_3/bin/llvm-config" arch -arm64 python3 -m pip install llvmlite
  4. Lastly, I succeeded to install pymde:
    python3 -m pip install pymde

Not sure this is the shortest and cleverest way, but it is the first way that perfectly works for me among the ones I tried!

akshayka commented 2 years ago

Sorry for the delay, and thank you for posting the solution!

I think this is likely due to the dependency on pynndescent, which uses numba, which in turn uses llvm for just-in-time code generation.

I will take closer look, and perhaps update the installation directions to point to your above comment.

Thank you!

kyleford8 commented 2 years ago

For what it's worth, I had the same issue, and can confirm the solution posted above works (been a while since I installed numba, but I remember having to do something nearly identical with llvmlite). In my case, it was definitely a numba/llvm issue, which also affects installation of UMAP (and probably many other packages) on M1 Macs.