我试图在MacOS10.14.5、Python3.7和gcc 4.7上安装Python (https://pypi.org/project/python-Levenshtein/)。但以下几个方面都失败了:
/opt/local/lib/gcc47/gcc/x86_64-apple-darwin16/4.7.4/include-fixed/limits.h:169:61: fatal error: limits.h: No such file or directory
完整的日志是:
pip3 install python-levenshtein
Collecting python-levenshtein
Using cached https://files.pythonhosted.org/packages/42/a9/d1785c85ebf9b7dfacd08938dd028209c34a0ea3b1bcdb895208bd40a67d/python-Levenshtein-0.12.0.tar.gz
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-levenshtein) (39.0.1)
Installing collected packages: python-levenshtein
Running setup.py install for python-levenshtein ... error
ERROR: Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/qg/vmj6zq4s7hb2pbkp3b8kstvh0000gn/T/pip-install-lougvxw2/python-levenshtein/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/qg/vmj6zq4s7hb2pbkp3b8kstvh0000gn/T/pip-record-4208lwgo/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/Levenshtein
copying Levenshtein/StringMatcher.py -> build/lib.macosx-10.9-x86_64-3.7/Levenshtein
copying Levenshtein/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/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
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-10.9-x86_64-3.7/Levenshtein
copying Levenshtein/_levenshtein.h -> build/lib.macosx-10.9-x86_64-3.7/Levenshtein
running build_ext
building 'Levenshtein._levenshtein' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/Levenshtein
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c Levenshtein/_levenshtein.c -o build/temp.macosx-10.9-x86_64-3.7/Levenshtein/_levenshtein.o
In file included from /opt/local/lib/gcc47/gcc/x86_64-apple-darwin16/4.7.4/include-fixed/syslimits.h:7:0,
from /opt/local/lib/gcc47/gcc/x86_64-apple-darwin16/4.7.4/include-fixed/limits.h:34,
from /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:11,
from Levenshtein/_levenshtein.c:99:
/opt/local/lib/gcc47/gcc/x86_64-apple-darwin16/4.7.4/include-fixed/limits.h:169:61: fatal error: limits.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/qg/vmj6zq4s7hb2pbkp3b8kstvh0000gn/T/pip-install-lougvxw2/python-levenshtein/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/qg/vmj6zq4s7hb2pbkp3b8kstvh0000gn/T/pip-record-4208lwgo/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qg/vmj6zq4s7hb2pbkp3b8kstvh0000gn/T/pip-install-lougvxw2/python-levenshtein/
felix@fxa-2:~$有趣的是,文件实际上存在于我的mac上,即:
felix@fxa-2:~$ ls /opt/local/lib/gcc47/gcc/x86_64-apple-darwin16/4.7.4/include-fixed
README limits.h math.h stdint.h syslimits.h发布于 2019-05-24 15:44:24
造成这个问题的原因是通过macport安装了gcc (4.7),以及xcode附带的另一个。第一个是用的。通过卸载带有macport的老gcc,xcode的gcc再次被使用,而也可以被安装(并编译它的C代码)。
发布于 2019-05-24 09:48:40
在我的机器上(不是Mac,但结果应该转换),…include-fixed/limits.h包含以下内容
#ifdef _GCC_NEXT_LIMITS_H
#include_next <limits.h> /* recurse down to the real one */
#endif在我的例子中,“真实的”似乎是/usr/include/limits.h:
$ <<< '#include <limits.h>' gcc -E -xc - |grep limits
# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 1 3 4
# 34 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 3 4
# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/syslimits.h" 1 3 4
# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 1 3 4
# 194 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 3 4
# 1 "/usr/include/limits.h" 1 3 4
# 26 "/usr/include/limits.h" 3 4
# 27 "/usr/include/limits.h" 2 3 4
# 183 "/usr/include/limits.h" 3 4
# 1 "/usr/include/linux/limits.h" 1 3 4
# 184 "/usr/include/limits.h" 2 3 4
# 188 "/usr/include/limits.h" 2 3 4
# 195 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 2 3 4
# 8 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/syslimits.h" 2 3 4
# 35 "/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed/limits.h" 2 3 4我的包裹经理说/usr/include/limits.h is owned by glibc 2.29-1。
而且你肯定有Mac的libc (不知道它叫什么)代替了Glibc。可能问题是,您的系统上的libc比gcc配置的libc更新得多(gcc 4.7现在已经相当老了),因此它希望在较新的版本中有被移动到另一个位置的头。
这是我的猜测。检查你的系统找出答案。此外,你也可以尝试一个较新的gcc建筑,如果这是一个选择。
发布于 2021-03-12 12:12:17
在我的例子中,默认的gcc是在/usr/local/bin/gcc中,它是到/usr/local/bin/gcc-4.9的软链接。
我用brew install gcc重新安装了brew install gcc,并将/usr/local/bin/gcc重新链接到新的gcc,这在我的例子中是/usr/local/bin/gcc-10。
对于g++也做了同样的事情,然后问题解决了。
https://stackoverflow.com/questions/56280122
复制相似问题