網站首頁 編程語言 正文
錯誤原因
在使用pip install dlib
安裝dlib
的時候報錯,錯誤的詳細信息如下
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)
接下來我們找錯誤提示的重點信息
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.
原因分析
從錯誤信息上來看是由于gcc的版本低于4.9導致無法支持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版本信息
來看,不應該出錯呀,因為gcc的版本已經大于4.9了。
出錯的原因在于安裝dlib的時候使用了conda的虛擬環境
,而在環境內有一個低于4.9的gcc,而默認使用的正是這個版本,所以導致出錯了。
解決辦法
- 改變conda環境下的gcc版本
- 查看conda環境下的gcc版本
gcc --version或gcc -v
- 替換gcc的版本
利用軟連接來覆蓋conda環境下的gcc版本,命令如下
ln -s /usr/local/bin/gcc /home/name/anconda3/envs/env_name/bin/gcc
- 找不到conda中安裝的gcc
我就屬于這種情況,在conda中找不到任何關于gcc的信息,在conda環境下使用gcc -v
輸出的版本也和沒有使用conda環境輸出的版本信息一致。
- 找到gcc的安裝位置
which gcc
#/usr/local/bin/gcc
- 導入環境變量
#激活conda環境
source activate cv
#設置環境變量
export CC=/usr/local/bin/gcc
- 終極解決辦法
在環境外編譯dlib
的源碼,生成whl文件,然后再環境內通過whl文件來安裝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
參考
原文鏈接:https://xiulian.blog.csdn.net/article/details/122740101
相關推薦
- 2022-06-15 C++模擬實現List迭代器詳解_C 語言
- 2023-01-13 Pytorch如何加載自己的數據集(使用DataLoader讀取Dataset)_python
- 2022-07-06 如何使用Python?OpenCV提取物體輪廓詳解_python
- 2023-05-08 Python中Generators教程的實現_python
- 2022-05-27 詳解Python實現字典合并的四種方法_python
- 2022-04-12 Oracle?Session每日統計功能實現_oracle
- 2022-06-06 uniApp實現滾動視圖點擊錨點跳轉、點擊左側分欄時右側對應內容置頂、左右分欄聯動、getSyste
- 2022-09-10 pycharm中沒有找到database的解決方案_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支