解決pip?install?dlib報(bào)錯(cuò)C++11?is?required?to?use?dlib
1.錯(cuò)誤原因
在使用pip install dlib
安裝dlib
的時(shí)候報(bào)錯(cuò),
錯(cuò)誤的詳細(xì)信息如下:
ERROR: Command errored out with exit status 1:
command: /root/miniconda3/envs/cv_1/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/setup.py’"’"’; file=’"’"’/tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-pi50j_zu
cwd: /tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/
Complete output (76 lines):
running bdist_wheel
running build
running build_py
package init file ‘tools/python/dlib/init.py’ not found (or not a regular file)
running build_ext
Building extension for Python 3.6.13 |Anaconda, Inc.| (default, Jun 4 2021, 14:25:59)
Invoking CMake setup: ‘cmake /tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/build/lib.linux-x86_64-3.6 -DPYTHON_EXECUTABLE=/root/miniconda3/envs/cv_1/bin/python -DCMAKE_BUILD_TYPE=Release’
– The C compiler identification is GNU 11.2.0
– The CXX compiler identification is GNU 4.8.5
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /usr/bin/cc - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: /usr/bin/c++ - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found PythonInterp: /root/miniconda3/envs/cv_1/bin/python (found version “3.6.13”)
– Found PythonLibs: /root/miniconda3/envs/cv_1/lib/libpython3.6m.so
– Performing Test HAS_CPP14_FLAG
– Performing Test HAS_CPP14_FLAG - Failed
– Performing Test HAS_CPP11_FLAG
– Performing Test HAS_CPP11_FLAG - Success
– pybind11 v2.2.4
– Using CMake version: 3.21.2
– Compiling dlib version: 19.23.0
CMake Error at /tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/dlib/cmake_utils/set_compiler_specific_options.cmake:50 (message):
C++11 is required to use dlib, but the version of GCC you are using is too
old and doesn’t support C++11. You need GCC 4.9 or newer.
Call Stack (most recent call first):
/tmp/pip-install-jpjqw_8i/dlib_a6680215d7d4421581b7b4999664056c/dlib/cmake_utils/test_for_sse4/CMakeLists.txt:8 (include)
接下來(lái)我們找錯(cuò)誤提示的重點(diǎn)信息:
C++11 is required to use dlib, but the version of GCC you are using is too
old and doesn’t support C++11. You need GCC 4.9 or newer.
2.原因分析
從錯(cuò)誤信息上來(lái)看是由于gcc的版本低于4.9導(dǎo)致無(wú)法支持C++ 11,查看gcc的版本
#查看gcc的版本信息 gcc --version :' gcc (GCC) 11.2.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. ?There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. '
從輸出的gcc
版本信息來(lái)看,不應(yīng)該出錯(cuò)呀,因?yàn)間cc的版本已經(jīng)大于4.9了。
出錯(cuò)的原因在于安裝dlib的時(shí)候使用了conda的虛擬環(huán)境,而在環(huán)境內(nèi)有一個(gè)低于4.9的gcc,而默認(rèn)使用的正是這個(gè)版本,所以導(dǎo)致出錯(cuò)了。
3.解決辦法
改變conda環(huán)境下的gcc版本:
1.查看conda環(huán)境下的gcc版本
gcc --version或gcc -v
2.替換gcc的版本
利用軟連接來(lái)覆蓋conda環(huán)境下的gcc版本
命令如下:
ln -s /usr/local/bin/gcc /home/name/anconda3/envs/env_name/bin/gcc
找不到conda中安裝的gcc:
我就屬于這種情況,在conda中找不到任何關(guān)于gcc的信息,在conda環(huán)境下使用gcc -v輸出的版本也和沒(méi)有使用conda環(huán)境輸出的版本信息一致。
1.找到gcc的安裝位置
which gcc #/usr/local/bin/gcc
2.導(dǎo)入環(huán)境變量
#激活conda環(huán)境 source activate cv #設(shè)置環(huán)境變量 export CC=/usr/local/bin/gcc
終極解決辦法:
在環(huán)境外編譯dlib
的源碼,生成whl文件,然后再環(huán)境內(nèi)通過(guò)whl文件來(lái)安裝dlib,
步驟如下:
#clone dlib的源碼 git clone https://github.com/davisking/dlib.git #編譯dlib mkdir build; cd build; cmake .. ; cmake --build . #安裝python版本的dlib python setup.py install
到此這篇關(guān)于pip install dlib
報(bào)錯(cuò)C++11 is required to use dlib
的文章就介紹到這了,更多相關(guān)報(bào)錯(cuò)C++11 is required to use dlib內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 15種?C++?常見(jiàn)報(bào)錯(cuò)原因分析
- c++報(bào)錯(cuò)問(wèn)題解決方案lvalue required as left operand of assignment
- C++?OpenCV裁剪圖片時(shí)發(fā)生報(bào)錯(cuò)的解決方式
- 如何基于C++解決RTSP取流報(bào)錯(cuò)問(wèn)題
- Python3安裝模塊報(bào)錯(cuò)Microsoft Visual C++ 14.0 is required的解決方法
- 解決安裝mysqlclient的時(shí)候出現(xiàn)Microsoft Visual C++ 14.0 is required報(bào)錯(cuò)
- C或C++報(bào)錯(cuò):ld returned 1 exit status報(bào)錯(cuò)的原因及解決方法
相關(guān)文章
一起來(lái)了解一下C++的結(jié)構(gòu)體?struct
這篇文章主要為大家詳細(xì)介紹了C++的結(jié)構(gòu)體struct,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-02-02C語(yǔ)言實(shí)現(xiàn)通訊錄的詳細(xì)代碼
本文詳細(xì)講解了C語(yǔ)言實(shí)現(xiàn)通訊錄的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單飛機(jī)大戰(zhàn)
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單飛機(jī)大戰(zhàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-02-02C語(yǔ)言數(shù)組越界引發(fā)的死循環(huán)問(wèn)題解決
本文主要介紹了C語(yǔ)言數(shù)組越界引發(fā)的死循環(huán)問(wèn)題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08