Python

FreeBSD Python 缺少標頭檔

  • July 9, 2020

我正在使用 FreeBSD 11、Python 3.7 和 clang 8.0.0,並且我正在嘗試使用pip. 但是當我嘗試安裝一個包時,例如pycurl,我收到一個錯誤,說它找不到 C 標頭檔limits.h

我使用這個命令來安裝pycurl

pip3.7 install pycurl

錯誤:

In file included from src/pycurl.h:5:<br/>
/usr/local/include/python3.7m/Python.h:11:10: fatal error: 'limits.h' file not found
#include <limits.h>
        ^~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1

為了獲得失去的標頭檔,我安裝了以下 FreeBSD 軟體包:

  • amd64-binutils-2.33.1_2.1
  • amd64-gcc-6.4.0_8
  • amd64-xtoolchain-gcc-0.4_1
  • llvm-devel-11.0.d20200519 # 是的,我知道這個沒有幫助,但我越來越絕望
  • mpc-1.1.0_2
  • mpfr-4.0.2
  • xtoolchain-llvm80-0.1

這會安裝limits.h文件,但現在當我編譯它時找不到syslimits.h.

我用這個命令安裝pycurl

pip3.7 install --global-option=build_ext --global-option=/x86_64-portbllib/gcc9/gcc/x86_64-portbld-tools/include/" pycurl

錯誤:

In file included from /usr/local/include/python3.7m/Python.h:11:
/usr/local/lib/gcc/x86_64-unknown-freebsd11.3/6.4.0/install-tools/include/limits.h:34:10: fatal error: 'syslimits.h' file not found
#include "syslimits.h"
        ^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1

為了安裝 Python 包,我需要安裝哪些包?

官方的 FreeBSD 軟體包已經包含ftp/py-pycurlpackage。你真的需要自己編譯嗎?

如果你這樣做,我建議安裝 FreeBSD Ports 樹並執行make -C /usr/ports/ftp/py-pycurl build命令來查看它是如何建構的。這應該可以讓您了解手動編譯時您做錯了什麼。

引用自:https://unix.stackexchange.com/questions/597412