解決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)文章
C++中的string庫(kù)函數(shù)常見(jiàn)函數(shù)的作用和使用方法
這篇文章主要介紹了C++中的string庫(kù)函數(shù)常見(jiàn)函數(shù)的作用和使用方法,庫(kù)函數(shù)的靈活應(yīng)用是程序員的一大重要技能,本文通過(guò)實(shí)例實(shí)例代碼給大家講解的非常詳細(xì),需要的朋友可以參考下2022-04-04
C++實(shí)現(xiàn)LeetCode(164.求最大間距)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(164.求最大間距),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07
關(guān)于C/C++中typedef的定義與用法總結(jié)
在C還是C++代碼中,typedef都使用的很多,在C代碼中尤其是多,typedef與#define有些相似,其實(shí)是不同的,特別是在一些復(fù)雜的用法上,需要的朋友可以參考下2012-12-12
C語(yǔ)言實(shí)現(xiàn)的學(xué)生選課系統(tǒng)代碼分享
這篇文章主要介紹了C語(yǔ)言實(shí)現(xiàn)的學(xué)生選課系統(tǒng)代碼分享,具有一定參考價(jià)值,需要的朋友可以了解下。2017-10-10

