ztane / python-Levenshtein

The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity
GNU General Public License v2.0
1.26k stars 155 forks source link

installation fails on MacOs 11.6 #80

Open hughjonesd opened 2 years ago

hughjonesd commented 2 years ago

Installing this via pip gives:

    Running setup.py install for python-Levenshtein ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/david/eebo-revo/env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-install-63nolnkf/python-levenshtein_b71ed4700818417a946a26877422615d/setup.py'"'"'; __file__='"'"'/private/var/folders/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-install-63nolnkf/python-levenshtein_b71ed4700818417a946a26877422615d/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/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-record-wkm2rfxg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/david/eebo-revo/env/include/site/python3.9/python-Levenshtein
         cwd: /private/var/folders/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-install-63nolnkf/python-levenshtein_b71ed4700818417a946a26877422615d/
    Complete output (32 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-11-x86_64-3.9
    creating build/lib.macosx-11-x86_64-3.9/Levenshtein
    copying Levenshtein/StringMatcher.py -> build/lib.macosx-11-x86_64-3.9/Levenshtein
    copying Levenshtein/__init__.py -> build/lib.macosx-11-x86_64-3.9/Levenshtein
    running egg_info
    writing python_Levenshtein.egg-info/PKG-INFO
    writing dependency_links to python_Levenshtein.egg-info/dependency_links.txt
    writing entry points to python_Levenshtein.egg-info/entry_points.txt
    writing namespace_packages to python_Levenshtein.egg-info/namespace_packages.txt
    writing requirements to python_Levenshtein.egg-info/requires.txt
    writing top-level names to python_Levenshtein.egg-info/top_level.txt
    adding license file 'COPYING' (matched pattern 'COPYING*')
    reading manifest file 'python_Levenshtein.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*pyc' found anywhere in distribution
    warning: no previously-included files matching '*so' found anywhere in distribution
    warning: no previously-included files matching '.project' found anywhere in distribution
    warning: no previously-included files matching '.pydevproject' found anywhere in distribution
    writing manifest file 'python_Levenshtein.egg-info/SOURCES.txt'
    copying Levenshtein/_levenshtein.c -> build/lib.macosx-11-x86_64-3.9/Levenshtein
    copying Levenshtein/_levenshtein.h -> build/lib.macosx-11-x86_64-3.9/Levenshtein
    running build_ext
    building 'Levenshtein._levenshtein' extension
    creating build/temp.macosx-11-x86_64-3.9
    creating build/temp.macosx-11-x86_64-3.9/Levenshtein
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/libffi/include -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/david/eebo-revo/env/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c Levenshtein/_levenshtein.c -o build/temp.macosx-11-x86_64-3.9/Levenshtein/_levenshtein.o
    clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11'
    error: command '/usr/bin/clang' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/david/eebo-revo/env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-install-63nolnkf/python-levenshtein_b71ed4700818417a946a26877422615d/setup.py'"'"'; __file__='"'"'/private/var/folders/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-install-63nolnkf/python-levenshtein_b71ed4700818417a946a26877422615d/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/xw/ttr6x0x97j328t5rh8bmky9h0000gn/T/pip-record-wkm2rfxg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/david/eebo-revo/env/include/site/python3.9/python-Levenshtein Check the logs for full command output.
WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/Users/david/eebo-revo/env/bin/python3 -m pip install --upgrade pip' command.
hughjonesd commented 2 years ago

This happened because I didn't have a recent enough version of clang as described here.

I fixed it by:

sudo xcode-select --switch /Library/Developer/CommandLineTools

after which installation worked.