Cython_bbox和搭接安装错误,#include "Python.h" 未找到



我在尝试安装这两个库(Cython_box和lap(时遇到了这些奇怪的错误,它们是我运行pip install -r requirements.txt时需要的其他库的一部分,其中包含以下

yacs
opencv-python
PyYAML
cython-bbox
scipy
progress
motmetrics
matplotlib
lap
openpyxl
Pillow
tensorboardX
fvcore

这可以从以下链接中找到:https://github.com/ifzhang/FairMOT

这是我犯的一大堆错误。

rc/cython_bbox.c:31:10: fatal error: Python.h: No such file or directory
31 | #include "Python.h"
|          ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for cython-bbox
Running setup.py clean for cython-bbox
Building wheel for lap (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/aevas/Desktop/pyenvs/fairmotpy39/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dweujmo4/lap_14d06a4a011f45a69d78f1a214bd5715/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dweujmo4/lap_14d06a4a011f45a69d78f1a214bd5715/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-pzh48d16
cwd: /tmp/pip-install-dweujmo4/lap_14d06a4a011f45a69d78f1a214bd5715/
Complete output (34 lines):
Partial import of lap during the build process.
Generating cython files
running bdist_wheel
running build
running config_cc
running config_fc
running build_src

SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/lap
copying lap/lapmod.py -> build/lib.linux-x86_64-3.9/lap
copying lap/__init__.py -> build/lib.linux-x86_64-3.9/lap
running build_ext
creating /tmp/tmpijpimqcg/home
creating /tmp/tmpijpimqcg/home/aevas
creating /tmp/tmpijpimqcg/home/aevas/Desktop
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/distutils
creating /tmp/tmpijpimqcg/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/distutils/checks
CCompilerOpt.generate_dispatch_header[2281] : dispatch header dir build/src.linux-x86_64-3.9/numpy/distutils/include does not exist, creating it
creating build/temp.linux-x86_64-3.9/lap
lap/_lapjv.cpp:4:10: fatal error: Python.h: No such file or directory
4 | #include "Python.h"
|          ^~~~~~~~~~
compilation terminated.
error: Command "x86_64-linux-gnu-g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-FZ7wim/python3.9-3.9.5=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/core/include -Ilap -I/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/home/aevas/Desktop/pyenvs/fairmotpy39/include -I/usr/include/python3.9 -c lap/_lapjv.cpp -o build/temp.linux-x86_64-3.9/lap/_lapjv.o -MMD -MF build/temp.linux-x86_64-3.9/lap/_lapjv.o.d -msse -msse2 -msse3" failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for lap



Running setup.py install for lap ... error
ERROR: Command errored out with exit status 1:
warnings.warn(
running build
running config_cc
running config_fc
running build_src
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/lap
copying lap/lapmod.py -> build/lib.linux-x86_64-3.9/lap
copying lap/__init__.py -> build/lib.linux-x86_64-3.9/lap
running build_ext
creating /tmp/tmplmbzif7h/home
creating /tmp/tmplmbzif7h/home/aevas
creating /tmp/tmplmbzif7h/home/aevas/Desktop
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/distutils
creating /tmp/tmplmbzif7h/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/distutils/checks
CCompilerOpt.generate_dispatch_header[2281] : dispatch header dir build/src.linux-x86_64-3.9/numpy/distutils/include does not exist, creating it
creating build/temp.linux-x86_64-3.9/lap
lap/_lapjv.cpp:4:10: fatal error: Python.h: No such file or directory
4 | #include "Python.h"
|          ^~~~~~~~~~
compilation terminated.
error: Command "x86_64-linux-gnu-g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-FZ7wim/python3.9-3.9.5=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/core/include -Ilap -I/home/aevas/Desktop/pyenvs/fairmotpy39/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/home/aevas/Desktop/pyenvs/fairmotpy39/include -I/usr/include/python3.9 -c lap/_lapjv.cpp -o build/temp.linux-x86_64-3.9/lap/_lapjv.o -MMD -MF build/temp.linux-x86_64-3.9/lap/_lapjv.o.d -msse -msse2 -msse3" failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1:

我把它安装在一个运行python3.9的全新虚拟环境中。我没有使用任何conda环境。如果需要,这是我的系统规格

11th Gen Intel® Core™ i7-11850H @ 2.50GHz × 16 
llvmpipe (LLVM 12.0.0, 256 bits) / Mesa Intel® UHD Graphics (TGL GT1)
Ubuntu 21.04 64-bit 

我尝试过的

  1. 浏览stackoverflow.com/search?q=%23include+%22Python.h%22+未找到+

试试这个:

sudo apt install libpython3.9-dev

它将安装像Python.h 这样的头文件

相关内容

  • 没有找到相关文章

最新更新