lap库就该这么安装
最近做的项目需要安装lap库,但是当我天真的输入pip install lap准备满心欢喜的等待安装成功却发现...,它报错了,这是一个从未见过的、非常长的报错,它长这个样子:
- pip3 install lap
- Collecting lap
- Using cached lap-0.4.0.tar.gz (1.5 MB)
- Preparing metadata (setup.py) ... done
- Building wheels for collected packages: lap
- Building wheel for lap (setup.py) ... error
- error: subprocess-exited-with-error
-
- × python setup.py bdist_wheel did not run successfully.
- │ exit code: 1
- ╰─> [59 lines of output]
- 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
- /home/max/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py:34: 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.8
- creating build/lib.linux-x86_64-3.8/lap
- copying lap/lapmod.py -> build/lib.linux-x86_64-3.8/lap
- copying lap/__init__.py -> build/lib.linux-x86_64-3.8/lap
- running build_ext
- creating /tmp/tmpayo2allo/tmp
- creating /tmp/tmpayo2allo/tmp/tmpayo2allo
- CCompilerOpt.__init__[955] : unable to detect compiler type which leads to treating it as GCC. this is a normal behavior if you're using gcc-like compiler such as MinGW or IBM/XLC.check dist_info:<<
- ('linux-x86_64', '/home/max/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc', '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/max/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/max/anaconda3/include')
- >>
- creating /tmp/tmp11lkyb7r/home
- creating /tmp/tmp11lkyb7r/home/max
- creating /tmp/tmp11lkyb7r/home/max/anaconda3
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils
- creating /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks
- CCompilerOpt.dist_test[576] : CCompilerOpt._dist_test_spawn[711] : Command (/home/max/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/max/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/max/anaconda3/include -fPIC -I/home/max/anaconda3/include/python3.8 -c /home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/test_flags.c -o /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/test_flags.o -MMD -MF /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/test_flags.o.d -mavx512vnni) failed with exit status 1 output ->
- x86_64-conda_cos6-linux-gnu-cc: error: unrecognized command line option '-mavx512vnni'; did you mean '-mavx5124vnniw'?
-
- CCompilerOpt.cc_test_flags[1003] : testing failed
- CCompilerOpt.dist_test[576] : CCompilerOpt._dist_test_spawn[711] : Command (/home/max/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/max/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/max/anaconda3/include -fPIC -I/home/max/anaconda3/include/python3.8 -c /home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.c -o /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.o -MMD -MF /tmp/tmp11lkyb7r/home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.o.d -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq -Werror) failed with exit status 1 output ->
- /home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.c: In function 'main':
- /home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.c:6:17: error: implicit declaration of function '_mm512_dpbusd_epi32'; did you mean '_mm512_4dpwssd_epi32'? [-Werror=implicit-function-declaration]
- __m512i a = _mm512_dpbusd_epi32(_mm512_setzero_si512(), _mm512_setzero_si512(), _mm512_setzero_si512());
- ^~~~~~~~~~~~~~~~~~~
- _mm512_4dpwssd_epi32
- /home/max/anaconda3/lib/python3.8/site-packages/numpy/distutils/checks/cpu_avx512_clx.c:6:17: error: incompatible types when initializing type '__m512i {aka __vector(8) long long int}' using type 'int'
- cc1: all warnings being treated as errors
-
- CCompilerOpt.feature_test[1458] : testing failed
- CCompilerOpt.generate_dispatch_header[2245] : dispatch header dir build/src.linux-x86_64-3.8/numpy/distutils/include does not exist, creating it
- creating /tmp/tmp2sxo2tvd/tmp
- creating /tmp/tmp2sxo2tvd/tmp/tmp2sxo2tvd
- creating build/temp.linux-x86_64-3.8/lap
- In file included from /home/max/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1944:0,
- from /home/max/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
- from /home/max/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
- from lap/_lapjv.cpp:581:
- /home/max/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
- #warning "Using deprecated NumPy API, disable it with " \
- ^~~~~~~
- /home/max/anaconda3/compiler_compat/ld: cannot find /lib/libpthread.so.0
- /home/max/anaconda3/compiler_compat/ld: cannot find /usr/lib/libpthread_nonshared.a
- collect2: error: ld returned 1 exit status
- error: Command "/home/max/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -pthread -shared -B /home/max/anaconda3/compiler_compat -L/home/max/anaconda3/lib -Wl,-rpath=/home/max/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/max/anaconda3/lib -Wl,-rpath-link,/home/max/anaconda3/lib -L/home/max/anaconda3/lib -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/max/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/max/anaconda3/include build/temp.linux-x86_64-3.8/lap/_lapjv.o build/temp.linux-x86_64-3.8/lap/lapjv.o build/temp.linux-x86_64-3.8/lap/lapmod.o -o build/lib.linux-x86_64-3.8/lap/_lapjv.cpython-38-x86_64-linux-gnu.so" failed with exit status 1
- [end of output]
-
- note: This error originates from a subprocess, and is likely not a problem with pip.
-
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [59 lines of output]
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
/home/max/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
天呐!这是什么错误?完全看不懂好吧...
后来又在网上反反复复找到了这样一条命令:
pip install git+git://github.com/gatagat/lap.git
作者打着包票跟我讲:这次一定行!
然后....(哎呦,真香,哎呦诶。)

注视:这是一条非常珍贵的命令!
conda install -c conda-forge lap
如果不是anaconda环境的小火炮可以试试将conda换成pip喔!
完毕!
如果大家觉得有帮助的话!麻烦点赞+收藏喔,谢谢大家!