安装python模块失败-缺少“ limits.h”吗?

苹果电脑

我正在尝试安装许多需要编译的python 3模块(例如regex,cytoolsz,spacy),但是它们全部失败,并出现与下面相同的错误(底部)。我试图使用下面的grep检查“ limits.h”是否存在。我已经重新安装了gcc,g ++ build-essentials,python3-dev等,但无济于事。

我在Ubuntu 18.10上。

dpkg -s gcc  
Package: gcc
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 50
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Source: gcc-defaults (1.179ubuntu1)
Version: 4:8.2.0-1ubuntu1
Provides: c-compiler, gcc-x86-64-linux-gnu (= 4:8.2.0-1ubuntu1)
Depends: cpp (= 4:8.2.0-1ubuntu1), gcc-8 (>= 8.2.0-4~)
Recommends: libc6-dev | libc-dev
Suggests: gcc-multilib, make, manpages-dev, autoconf, automake, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Description: GNU C compiler
 This is the GNU C compiler, a fairly portable optimizing compiler for C.
 .
 This is a dependency package providing the default GNU C compiler.
Original-Maintainer: Debian GCC Maintainers <[email protected]>

查看:

x86_64-linux-gnu-gcc -xc -E -v /dev/null

Using built-in specs.
COLLECT_GCC=x86_64-linux-gnu-gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.2.0-7ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-7ubuntu1) 
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/8/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu /dev/null -mtune=generic -march=x86-64 -fstack-protector-strong -Wformat -Wformat-security
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/8/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
# 1 "/dev/null"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "/dev/null"
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'

查看:

dpkg -S limits.h | grep linux
linux-headers-4.18.0-15: /usr/src/linux-headers-4.18.0-15/include/linux/dynamic_queue_limits.h
linux-libc-dev:amd64: /usr/include/linux/limits.h
linux-headers-4.19.0-041900rc8: /usr/src/linux-headers-4.19.0-041900rc8/include/uapi/linux/limits.h
linux-headers-4.18.0-14: /usr/src/linux-headers-4.18.0-14/include/linux/drbd_limits.h
linux-headers-4.18.0-15: /usr/src/linux-headers-4.18.0-15/arch/arm/include/asm/limits.h
linux-headers-4.18.0-14: /usr/src/linux-headers-4.18.0-14/include/uapi/linux/limits.h
linux-headers-4.18.0-14: /usr/src/linux-headers-4.18.0-14/include/linux/dynamic_queue_limits.h
libgcc-8-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed/limits.h
linux-headers-4.18.0-14: /usr/src/linux-headers-4.18.0-14/arch/arm/include/asm/limits.h
linux-headers-4.18.0-15: /usr/src/linux-headers-4.18.0-15/include/linux/drbd_limits.h
linux-headers-4.19.0-041900rc8: /usr/src/linux-headers-4.19.0-041900rc8/include/linux/drbd_limits.h
linux-headers-4.18.0-15: /usr/src/linux-headers-4.18.0-15/include/uapi/linux/limits.h
linux-headers-4.19.0-041900rc8: /usr/src/linux-headers-4.19.0-041900rc8/include/linux/dynamic_queue_limits.h
linux-headers-4.19.0-041900rc8: /usr/src/linux-headers-4.19.0-041900rc8/arch/arm/include/asm/limits.h
libgcc-8-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed/syslimits.h

错误:

    sudo pip3 install regex                   
The directory '/home/mac/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mac/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting regex
  Downloading https://files.pythonhosted.org/packages/9a/6f/8c1479c781bbc94394f9c4e33ad4139068bcc6a1b018c5a5525471262b8a/regex-2019.02.18.tar.gz (643kB)
    100% |████████████████████████████████| 645kB 813kB/s 
Installing collected packages: regex
  Running setup.py install for regex ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n16bk3y6/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-z1rqj4ab-record/install-record.txt --single-version-externally-managed --compile:
    /home/mac/.local/lib/python3.6/site-packages/setuptools/dist.py:475: UserWarning: Normalizing '2019.02.18' to '2019.2.18'
      normalized_version,
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    copying regex_3/regex.py -> build/lib.linux-x86_64-3.6
    copying regex_3/_regex_core.py -> build/lib.linux-x86_64-3.6
    copying regex_3/test_regex.py -> build/lib.linux-x86_64-3.6
    running build_ext
    building '_regex' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/regex_3
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.6/regex_3/_regex.o
    In file included from /usr/include/python3.6m/Python.h:11,
                     from regex_3/_regex.c:48:
    /usr/include/limits.h:124:26: error: no include path in which to search for limits.h
     # include_next <limits.h>
                              ^
    In file included from regex_3/_regex.c:48:
    /usr/include/python3.6m/Python.h:14:2: error: #error "Something's broken.  UCHAR_MAX should be defined in limits.h."
     #error "Something's broken.  UCHAR_MAX should be defined in limits.h."
      ^~~~~
    /usr/include/python3.6m/Python.h:18:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type."
     #error "Python's source code assumes C's unsigned char is an 8-bit type."
      ^~~~~
    In file included from /usr/include/python3.6m/Python.h:25,
                     from regex_3/_regex.c:48:
    /usr/include/stdio.h:33:10: fatal error: stddef.h: No such file or directory
     #include <stddef.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n16bk3y6/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-z1rqj4ab-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-n16bk3y6/regex/

双方linux-libc-devlibc6-dev已安装,我也试着重新安装两者。我的PATH是:

$ echo $PATH
/home/mac/.opam/system/bin:/home/mac/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 

我还尝试了引导到更早的内核4.18.0,但是结果是相同的。

温柔的猫为莫妮卡鼓掌

分析(您可以跳过它,但将来可能有助于诊断类似问题)

您的GCC抱怨另一个文件)limits.h引用的文件丢失/usr/include/limits.h limits.h

/usr/include/limits.h:124:26: error: no include path in which to search for limits.h

经过检查,/usr/include/limits.h我们可以看到以下内容:

$ sed -n 117,125p /usr/include/limits.h
 /* Get the compiler's limits.h, which defines almost all the ISO constants.

    We put this #include_next outside the double inclusion check because
    it should be possible to include this file more than once and still get
    the definitions from gcc's header.  */
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
/* `_GCC_LIMITS_H_' is what GCC's file defines.  */
# include_next <limits.h>
#endif

换句话说,libclimits.h包括编译器本身提供另一个 limits.h使用该apt-file工具和一些常识,我们可以确定您需要的软件包是libgcc-8-dev

$ apt-file search /limits.h | grep gcc-8
libgcc-8-dev: /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed/limits.h
...

您的dpkg查询列出了已安装的软件包和文件:

$ dpkg -S limits.h | grep linux
libgcc-8-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed/limits.h
...

但是,GCC抱怨缺少目录:

$ x86_64-linux-gnu-gcc -xc -E -v /dev/null
...
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed"

结论和修正

所有这些可能意味着libgcc-8-dev软件包在您的系统上以某种方式被破坏了。要还原它,请运行:

$ sudo apt-get install --reinstall libgcc-8-dev

(您可能需要替换为8拥有的适当的主要GCC版本)

通常,如果您不记得手动limits.h从系统中删除文件或以其他任何方式修改GCC安装,则最好检查文件系统的一致性和硬盘运行状况。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

LAMP缺少PHP模块吗?

来自分类Dev

snapcraft snap失败,因为缺少python模块

来自分类Dev

Python模块安装失败,因为gcc命令缺少标志... gcc命令具有

来自分类Dev

安装Cabal缺少模块

来自分类Dev

安装fglrx时缺少“ version.h”

来自分类Dev

Heroku App缺少HTML模块吗?

来自分类Dev

使用PIP安装的PyAudio缺少文件吗?

来自分类Dev

草莓安装程序缺少点子吗?

来自分类Dev

Python:缺少Python.h文件

来自分类Dev

缺少Python.h,无法找到

来自分类Dev

Python-缺少模块

来自分类Dev

Nokogiri安装失败,缺少libxslt

来自分类Dev

是#include <limits>跨平台的吗?

来自分类Dev

X11 / Xlib.h中缺少XGetPixel()吗?

来自分类Dev

mingw中似乎缺少Winsock2.h吗?

来自分类Dev

在Alpine Linux上安装Pillow时,没有这样的文件或目录“ limits.h”

来自分类Dev

安装软件包时缺少pyconfig.h

来自分类Dev

通过pip安装pycups缺少cups.h?

来自分类Dev

无法在OSX上安装摘要gem,缺少glib.h

来自分类Dev

缺少安装KB4346783的WinPE软件包吗?

来自分类Dev

“ Python ssl扩展未编译。缺少OpenSSL库吗?” 使用pyenv安装Python时出现错误

来自分类Dev

Python Tornado:缺少WSGI模块?

来自分类Dev

缺少PHP包含(.h)

来自分类Dev

缺少modversions.h

来自分类Dev

ValueError:请求网址中缺少方案:python中的h

来自分类Dev

Windows(C)上的limits_h宏

来自分类Dev

如果安装失败,npm会删除下载的模块吗?

来自分类Dev

Angular 2缺少模块

来自分类Dev

CMake缺少模块目录