vault简介 安装 在centos上安装 $ sudo yum install -y yum-utils $ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo $ sudo yum -y install vault 在ubuntu上安装 $ sudo apt update && sudo apt install gpg $ wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg >/dev/null $ gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint $ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install vault mac上安装 $ brew tap hashicorp/tap $ brew install hashicorp/tap/vault $ brew upgrade hashicorp/tap/vault # 升级 windows上安装 choco install vault 测试环境启动vault服务 这种用法仅限于测试环境，生产环境后面我们在说 开发模式启动 $ vault server -dev WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory and starts unsealed with a single unseal key. The root token is already authenticated to the CLI, so you can immediately begin using Vault. You may need to set the following environment variables: $ export VAULT_ADDR='http://127.0.0.1:8200' The unseal key and root token are displayed below in case you want to seal/unseal the Vault or re-authenticate. Unseal Key: 910jSSp6agJyY0RNm2QnamUtv3IZNcdJp0DejDE3OvI= Root Token: hvs.Wlq6tyxrx2kS5IQSJI1F7b1l ！！！！！重要重要重要！！！！！ Development mode should NOT be used in production installations! $ export VAULT_ADDR='http://127.0.0.1:8200' # 把vault服务地址写入环境变量 $ export VAULT_TOKEN='hvs.Wlq6tyxrx2kS5IQSJI1F7b1l' # 把root token写入环境变量 可以开始测试vault了 这里我们先使用简单的kv引擎,kv存储引擎会以明文方式把信息放在内存里。vault还支持其他的secrets engine，后面再说。 写入信息 $ vault kv put -mount=secret hello foo=world # 向hello写入一个kv foo=world == Secret Path == secret/data/hello ======= Metadata ======= Key Value --- ----- created_time 2023-01-04T05:39:57.252132156Z custom_metadata <nil> deletion_time n/a destroyed false version 1 $ vault kv put -mount=secret hello foo=world excited=yes # 一次写入多个 == Secret Path == secret/data/hello ======= Metadata ======= Key Value --- ----- created_time 2023-01-04T05:47:08.162563361Z custom_metadata <nil> deletion_time n/a destroyed false version 2 读取信息 $ vault kv get -mount=secret hello # 读取 == Secret Path == secret/data/hello ======= Metadata ======= Key Value --- ----- created_time 2023-01-04T05:47:08.162563361Z custom_metadata <nil> deletion_time n/a destroyed false version 2 ===== Data ===== Key Value --- ----- excited yes foo world $ vault kv get -mount=secret -field=excited hello # 读取excited yes $ vault kv get -mount=secret -field=foo hello # 读取foo world 删除信息 $ vault kv delete -mount=secret hello # 删除 Success! Data deleted (if it existed) at: secret/data/hello 恢复删除的信息 $ vault kv undelete -mount=secret -versions=2 hello # 恢复删除的数据 Success! Data written to: secret/undelete/hello $ vault kv get -mount=secret hello #读取 == Secret Path == secret/data/hello ======= Metadata ======= Key Value --- ----- created_time 2023-01-04T05:47:08.162563361Z custom_metadata <nil> deletion_time n/a destroyed false version 2 ===== Data ===== Key Value --- ----- excited yes foo world secrets存储引擎 启用secrets engine $ vault secrets enable -path=kv kv Success! Enabled the kv secrets engine at: kv/ 查看secrets engine $ vault secrets list Path Type Accessor Description ---- ---- -------- ----------- cubbyhole/ cubbyhole cubbyhole_4a6f3187 per-token private secret storage identity/ identity identity_b7f7c47e identity store kv/ kv kv_886c0760 n/a secret/ kv kv_90394201 key/value secret storage sys/ system system_1b527783 system endpoints used for control, policy and debugging 写入信息 $ vault kv put kv/hello target=world Success! Data written to: kv/hello $ vault kv put kv/my-secret value="s3c(eT" Success! Data written to: kv/hello 读取 $ vault kv get kv/my-secret ==== Data ==== Key Value --- ----- value s3c(eT 删除 $ vault kv delete kv/my-secret Success! Data deleted (if it existed) at: kv/my-secret 关闭secret engine $ vault secrets disable kv/ Success! Disabled the secrets engine (if it existed) at: kv/ dynamic secrets 可以使用aws存储密码信息，vault远程读取。需要了解请参考官方文档。https://developer.hashicorp.com/vault/tutorials/getting-started/getting-started-dynamic-secrets 安全认证 这里主要有两种认证方式 token认证 github credentials认证 本文只关注token认证方式，需要了解github credential方式的，参考官方文档。https://developer.hashicorp.com/vault/tutorials/getting-started/getting-started-authentication token认证方式默认出狱开启状态，dev模式启动vault时候，他会显示root token信息。vault命令行会从环境变量$VAULT_TOKEN中读取root token完成授权。因此，需要设置环境变量 $ export VAULT_TOKEN='hvs.Wlq6tyxrx2kS5IQSJI1F7b1l' # 把root token写入环境变量 创建新的token $ vault token create Key Value --- ----- token hvs.AH1OvBNx2EG76sp3OiIJq43Z token_accessor Rf4yUJ16Q8nEUuTJsS7Z4zXQ token_duration ∞ token_renewable false token_policies ["root"] identity_policies [] policies ["root"] 使用新token登录 $ unset VAULT_TOKEN # 注销掉之前的root token $ vault login Token (will be hidden): #此处输入上面的tokenhvs.AH1OvBNx2EG76sp3OiIJq43Z Success! You are now authenticated. The token information displayed below is already stored in the token helper. You do NOT need to run "vault login" again. Future Vault requests will automatically use this token. Key Value --- ----- token hvs.AH1OvBNx2EG76sp3OiIJq43Z token_accessor Rf4yUJ16Q8nEUuTJsS7Z4zXQ token_duration ∞ token_renewable false token_policies ["root"] identity_policies [] policies ["root"] 注销token $ vault token revoke hvs.AH1OvBNx2EG76sp3OiIJq43Z Success! Revoked token (if it existed) 生产环境部署vault 先取消VAULT_TOKEN $ unset VAULT_TOKEN vault配置文件config.hcl,内容 storage "raft" { path = "./vault/data" node_id = "node1" } listener "tcp" { address = "127.0.0.1:8200" tls_disable = "true" } api_addr = "http://127.0.0.1:8200" cluster_addr = "https://127.0.0.1:8201" ui = true 配置文件解释 storage：指定vault存储的物理后端。dev模式服务使用inmem后端，这里我们使用raft后端，更佳适用于生产环境 listener：监听地址，用于处理api请求。这里使用http://127.0.0.1:8200，我们只要设置环境变量VAULT_ADDR=http://127.0.0.1:8200，vault客户端就可以连接了 api_addr：指定处理客户请求的地址 cluster_addr：指定vault node之间通信的地址和端口 启动服务 $ mkdir -p ./vault/data # 创建数据目录 $ vault server -config=config.hcl
问题 机器学习需要安装dlib库，网上搜索 解决方案在最底部 网上搜索的解决方案 pip install cmake pip install boost pip install dlib 然而，在安装dlib的时候，错误原因不仅限于没有安装cmake。 报错如下 Collecting dlib Using cached dlib-19.24.0.tar.gz (3.2 MB) Preparing metadata (setup.py) ... done Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [320 lines of output] 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.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\lib.win-amd64-3.8 -DPYTHON_EXECUTABLE=C:\ProgramData\Anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\lib.win-amd64-3.8 -A x64' -- Building for: Visual Studio 17 2022 -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044. -- The C compiler identification is MSVC 19.32.31329.0 -- The CXX compiler identification is MSVC 19.32.31329.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - 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: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonInterp: C:/ProgramData/Anaconda3/python.exe (found version "3.8.8") -- Found PythonLibs: C:/ProgramData/Anaconda3/libs/Python38.lib -- pybind11 v2.2.4 -- Using CMake version: 3.22.5 -- Compiling dlib version: 19.24.0 -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void* -- Check size of void* - done -- Enabling SSE2 instructions -- Searching for BLAS and LAPACK -- Searching for BLAS and LAPACK -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE -- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2 (found suitable version "11.2", minimum required is "7.5") -- Looking for cuDNN install... -- Found cuDNN: C:/tools/cudnn-11.2-windows-x64-v8.1.1.33/cuda/lib/x64/cudnn.lib -- Building a CUDA test project to see if your compiler is compatible with CUDA... -- ***************************************************************************************************************** -- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. -- *** The output of the failed CUDA test compile is shown below: -- *** -- *** Change Dir: C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release/dlib_build/cuda_test_build *** *** Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe ALL_BUILD.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework *** Copyright (C) Microsoft Corporation. All rights reserved. *** *** C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\ZERO_CHECK.vcxproj] *** Checking Build System *** C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj] *** Building NVCC (Device) object CMakeFiles/cuda_test.dir/Debug/cuda_test_generated_cuda_test.cu.obj *** cuda_test.cu *** C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\crt/host_config.h(160): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj] *** CUSTOMBUILD : nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning). [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj] *** CUSTOMBUILD : nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj] *** CMake Error at cuda_test_generated_cuda_test.cu.obj.Debug.cmake:216 (message): *** Error generating *** C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release/dlib_build/cuda_test_build/CMakeFiles/cuda_test.dir//Debug/cuda_test_generated_cuda_test.cu.obj *** *** *** C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for 'C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\cmake_utils\test_for_cuda\cuda_test.cu;C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\cmake_utils\test_for_cuda\CMakeLists.txt' exited with code 1. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj] *** *** -- ***************************************************************************************************************** -- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA -- C++11 activated. -- Configuring done -- Generating done -- Build files have been written to: C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release Invoking CMake build: 'cmake --build . --config Release -- /m' Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\ZERO_CHECK.vcxproj] Checking Build System C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] Building Custom Rule C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/dlib/CMakeLists.txt base64_kernel_1.cpp bigint_kernel_1.cpp bigint_kernel_2.cpp bit_stream_kernel_1.cpp entropy_decoder_kernel_1.cpp entropy_decoder_kernel_2.cpp entropy_encoder_kernel_1.cpp entropy_encoder_kernel_2.cpp md5_kernel_1.cpp tokenizer_kernel_1.cpp unicode.cpp test_for_odr_violations.cpp sockets_kernel_1.cpp bsp.cpp dir_nav_kernel_1.cpp dir_nav_kernel_2.cpp dir_nav_extensions.cpp fonts.cpp linker_kernel_1.cpp extra_logger_headers.cpp logger_kernel_1.cpp logger_config_file.cpp misc_api_kernel_1.cpp misc_api_kernel_2.cpp sockets_extensions.cpp sockets_kernel_2.cpp sockstreambuf.cpp sockstreambuf_unbuffered.cpp server_kernel.cpp server_iostream.cpp server_http.cpp multithreaded_object_extension.cpp threaded_object_extension.cpp threads_kernel_1.cpp threads_kernel_2.cpp threads_kernel_shared.cpp thread_pool_extension.cpp async.cpp timer.cpp stack_trace.cpp cpu_dlib.cpp tensor_tools.cpp image_dataset_metadata.cpp mnist.cpp cifar.cpp global_function_search.cpp kalman_filter.cpp auto.cpp widgets.cpp drawable.cpp canvas_drawing.cpp style.cpp base_widgets.cpp gui_core_kernel_1.cpp gui_core_kernel_2.cpp png_loader.cpp save_png.cpp jpeg_loader.cpp save_jpeg.cpp arm_init.c filter_neon_intrinsics.c png.c pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(319,17): warning C4267: “=”: 从“size_t”转换到“unsigned int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] inffast.c inflate.c inftrees.c trees.c uncompr.c C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(400,11): warning C4267: “=”: 从“size_t”转换到“unsigned int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(212,24): warning C4267: “=”: 从“size_t”转换到“unsigned int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] zutil.c jaricom.c C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(472,11): warning C4267: “=”: 从“size_t”转换到“int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(232,21): warning C4267: “=”: 从“size_t”转换到“unsigned int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(371,11): warning C4267: “=”: 从“size_t”转换到“int”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcprepct.c jcsample.c jdapimin.c jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jdatadst.c(185,34): warning C4267: “=”: 从“size_t”转换到“unsigned long”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdpostct.c jdsample.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jmemmgr.c jmemnobs.c jquant1.c jquant2.c jutils.c C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(307,47): warning C4267: “+=”: 从“size_t”转换到“long”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jerror.c(193,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(367,46): warning C4267: “+=”: 从“size_t”转换到“long”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jerror.c(195,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(977,35): warning C4267: “-=”: 从“size_t”转换到“long”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(991,35): warning C4267: “-=”: 从“size_t”转换到“long”，可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(1107,19): warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(1110,11): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj] dlib.vcxproj -> C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\Release\dlib19.24.0_release_64bit_msvc1932.lib C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] Building Custom Rule C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/tools/python/CMakeLists.txt dlib.cpp matrix.cpp vector.cpp svm_c_trainer.cpp svm_rank_trainer.cpp decision_functions.cpp other.cpp basic.cpp cca.cpp sequence_segmenter.cpp svm_struct.cpp image.cpp image2.cpp image3.cpp image4.cpp rectangles.cpp C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\dlib.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\matrix.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\cca.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\decision_functions.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\other.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_rank_trainer.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\vector.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image2.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] object_detection.cpp C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\basic.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] shape_predictor.cpp C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\rectangles.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image4.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] correlation_tracker.cpp C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_c_trainer.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\sequence_segmenter.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image3.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_struct.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] face_recognition.cpp cnn_face_detector.cpp global_optimization.cpp image_dataset_metadata.cpp numpy_returns.cpp line.cpp gui.cpp C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\object_detection.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\shape_predictor.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\correlation_tracker.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\face_recognition.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\global_optimization.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\cnn_face_detector.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image_dataset_metadata.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\numpy_returns.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\line.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的，则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\gui.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 222, in <module> setup( File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\__init__.py", line 165, in setup return distutils.core.setup(**attrs) File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\ProgramData\Anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 299, in run self.run_command('build') File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\ProgramData\Anaconda3\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 174, in build_extension subprocess.check_call(cmake_build, cwd=build_folder) File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib Running setup.py install for dlib ... / 关键错误 #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64- 我推测关键错误原因还是visual studio版本的问题。我本机有vs2019和vs2022，python应该是使用了vs2022。然而这个版本不被支持 解决方法 下载dlib包，手动执行setup.py,加上参数 下载地址： https://github.com/davisking/dlib/tags 解压缩执行命令,cmd打开目录 C:\Users\machineA\Desktop\dlib-19.24>> python setup.py install --no DLIB_GIF_SUPPORT 。。。。。 creating dist creating 'dist\dlib-19.24.0-py3.8-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing dlib-19.24.0-py3.8-win-amd64.egg creating c:\programdata\anaconda3\lib\site-packages\dlib-19.24.0-py3.8-win-amd64.egg Extracting dlib-19.24.0-py3.8-win-amd64.egg to c:\programdata\anaconda3\lib\site-packages Adding dlib 19.24.0 to easy-install.pth file Installed c:\programdata\anaconda3\lib\site-packages\dlib-19.24.0-py3.8-win-amd64.egg Processing dependencies for dlib==19.24.0 Finished processing dependencies for dlib==19.24.0
关键问题 WSL每次启动ip不一样，所以不能用静态方法设置http代理。 WSL会把宿主ip地址写入 获得当前宿主ip地址的方法 cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }' 手动设置代理的方法 $ cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }' 172.29.176.1 $ export https_proxy="http://172.29.190.80:10000" # 下载github库 $ wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip --2022-06-05 01:46:58-- https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip 正在连接 172.29.176.1:10000... 已连接。 已发出 Proxy 请求，正在等待回应... 302 Found 位置：https://objects.githubusercontent.com/github-production-release-asset-2e65be/274594200/49cb1e00-e34c-11eb-82bf-3c592a7d16da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220604%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220604T174658Z&X-Amz-Expires=300&X-Amz-Signature=5ce75d01ba6ee4cb9c9ca3190282bb603552cc90a8e9cb64797eb9e19e6cc6ba&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=274594200&response-content-disposition=attachment%3B%20filename%3Dface_checkpoints.zip&response-content-type=application%2Foctet-stream [跟随至新的 URL] --2022-06-05 01:46:58-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/274594200/49cb1e00-e34c-11eb-82bf-3c592a7d16da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220604%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220604T174658Z&X-Amz-Expires=300&X-Amz-Signature=5ce75d01ba6ee4cb9c9ca3190282bb603552cc90a8e9cb64797eb9e19e6cc6ba&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=274594200&response-content-disposition=attachment%3B%20filename%3Dface_checkpoints.zip&response-content-type=application%2Foctet-stream 正在连接 172.29.176.1:10000... 已连接。 已发出 Proxy 请求，正在等待回应... 200 OK 长度： 684354563 (653M) [application/octet-stream] 正在保存至: ‘face_checkpoints.zip’ face_checkpoints.zip 100%[================================================================================================================================>] 652.65M 3.68MB/s 用时 2m 41s 2022-06-05 01:49:40 (4.06 MB/s) - 已保存 ‘face_checkpoints.zip’ [684354563/684354563]) 启动时候自动设置的方法 脚本/usr/bin/proxy.sh, 记得替换成自己本机代理端口 #!/bin/sh hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }') wslip=$(hostname -I | awk '{print $1}') port=10000 PROXY_HTTP="http://${hostip}:${port}" set_proxy(){ export http_proxy="${PROXY_HTTP}" export HTTP_PROXY="${PROXY_HTTP}" export https_proxy="${PROXY_HTTP}" export HTTPS_proxy="${PROXY_HTTP}" } unset_proxy(){ unset http_proxy unset HTTP_PROXY unset https_proxy unset HTTPS_PROXY } test_setting(){ echo "Host ip:" ${hostip} echo "WSL ip:" ${wslip} echo "Current proxy:" $https_proxy } if [ "$1" = "set" ] then set_proxy elif [ "$1" = "unset" ] then unset_proxy elif [ "$1" = "test" ] then test_setting else echo "Unsupported arguments." fi 需要使用代理时 source proxy.sh set 取消代理 source proxy.sh unset 参考链接 https://zinglix.xyz/2020/04/18/wsl2-proxy/
创建dockerfile FROM golang:1.17-alpine # Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so: # docker build --build-arg HUGO_BUILD_TAGS=extended . ARG HUGO_BUILD_TAGS ARG CGO=1 ENV CGO_ENABLED=${CGO} ENV GOOS=linux ENV GO111MODULE=on ENV HUGO_VERSION=0.93.3 ENV HUGO_USER=hugo ENV BASE_DIRECORY=/home/hugo ENV SITE_NAME=hugosite ENV HUGO_SITE_DIRECORY=${BASE_DIRECORY}/${SITE_NAME} ENV HUGO_URL=https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz #hugo_extended_0.93.3_Linux-64bit.tar.gz ENV GLIBC_VER=2.34-r0 ENV GLIBC_NAME=glibc-${GLIBC_VER}.apk ENV THEME_NAME=book ENV THEME_URL=https://github.com/alex-shpak/hugo-book RUN set -ex && \ apk --update add libstdc++ curl ca-certificates git # glibc ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc ENV GLIBC_VERSION=2.30-r0 RUN set -ex && \ apk --update add libstdc++ curl ca-certificates && \ for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \ do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \ apk add --allow-untrusted /tmp/*.apk && \ rm -v /tmp/*.apk && \ /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib # 下载安装 ADD ${HUGO_URL} /tmp/ RUN tar -xzf /tmp/*.tar.gz -C /tmp && \ file="$(echo HUGO_URL)" && echo $file && \ file="$(ls -ll /tmp/hugo)" && echo $file && \ mv /tmp/hugo /usr/bin/ && \ #rm -rf /tmp/* && \ file="$(ls -ll /usr/bin/hugo)" && echo $file && \ adduser ${HUGO_USER} -D #CMD sh WORKDIR ${BASE_DIRECORY} #VOLUME ["$BASE_DIRECORY", "$BASE_DIRECORY"] #CMD ["ls","-a"] # 安装 RUN hugo new site ${SITE_NAME} # && file="$(ls -ll /home/hugo/hugosite)" && echo $file && echo $file && file="$(pwd)" && echo $file WORKDIR ${HUGO_SITE_DIRECORY} RUN git init \ && git submodule add ${THEME_URL} themes/${THEME_NAME} \ && cp -R themes/${THEME_NAME}/exampleSite/content . \ && echo -e "baseURL = 'http://example.org/' \r\nlanguageCode = 'en-us' \r\ntitle = 'My New Hugo Site' \r\ntheme = '${THEME_NAME}'" > config.toml EXPOSE 20000 CMD ["hugo", "server", "-D", "--bind", "0.0.0.0", "--port", "20000"] #CMD sh 构建运行镜像 docker build -f ./Dockerfile.hugo -t myhugo . docker run -i -t -p 20000:20000 myhugo 配置物理机上nginx转发到docker容器 vim nginx/conf/vhost/域名.conf server { listen 80; #listen [::]:80 default_server; server_name 域名; location / { access_log 访问日志文件; error_log 错误日志文件; proxy_pass http://127.0.0.1:20000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
cat连用grep进行筛选，筛选出的json还可以提取key 距离提取满足grep筛选条件的记录，并提取MessageID字段内容 cat log-20210326-* | grep xxx | grep MessageID | grep -Po 'MessageID[" :]+\K[^"]+'
查看当前linux自带jdk是否安装,以及jdk版本 java -version rpm -qa | grep java rpm -qa | grep gcj rpm -qa | grep jdk # 如果已经有jdk, 会显示如下 java-x.x.x-gcj-compat-x.x.x.x-xxjpp.xxx java-x.x.x-openjdk-x.x.x.x-x.x.bxx.exx 如果有已安装的jdk，则挨个卸载，没有则跳过这一步 rpm -e –nodeps java-x.x.x-gcj-compat-x.x.x.x-xxjpp.xxx rpm -e –nodeps java-x.x.x-openjdk-x.x.x.x-x.x.bxx.exx 如果找不到openjdk source，还可以如下方法卸载 yum -y remove java java-x.x.x-gcj-compat-x.x.x.x-xxjpp.xxx yum -y remove java java-x.x.x-openjdk-x.x.x.x-x.x.bxx.exx 官网下载jdk，并安装。 https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html 我们使用：Linux x64 Compressed Archive. # 下载之后解压缩 tar -zxvf jdk-8u261-linux-x64.tar.gz # 移动到/usr/local/ mv jdk1.8.0_261 /usr/local/ 设置环境变量 vim /etc/profile # 环境变量设置 #JDK1.8 export JAVA_HOME=/usr/local/jdk1.8.0_261 export JAVA_BIN=/usr/local/jdk1.8.0_261/bin export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN PATH CLASSPATH 测试安装 执行java -version和javac
pypetter能做什么 自行百度 为什么没法下载 省略原因，只有mmp 解决方法 1 既然无法下载，那我们就手动下载然后放到指定位置么。问题来了 从哪下载 放到哪里 从哪里下载 找这个文件：find / -name chromium_downloader.py python 3.8环境下，找到文件：/usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py 备份py库文件稍后恢复，/usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py 编辑 vim /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py 备份 mv /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py.bak /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.p 稍后恢复 mv /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py.bak /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py def download_zip(url: str) -> BytesIO: """Download data from url.""" logger.warning('start chromium download.\n' 'Download may take a few minutes.') print("下载地址" + url) # 打印下载地址 运行python程序，pyppeteer输出下载链接 https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/588429/chrome-linux.zip 有了url，方便下载了吧。再不会那就要去搜别的主题了。 放到哪里 同上打开上面那个py文件 在chromium_executable()函数中增加print打印目录 def chromium_executable() -> Path: """Get path of the chromium executable.""" print(chromiumExecutable[current_platform()]) return chromiumExecutable[current_platform()] 得到存储位置 /root/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome 对应存储目录：/root/.local/share/pyppeteer/local-chromium/588429/chrome-linux/ 创建子目录，放入chromium运行测试 ls /root/.local/share/pyppeteer/ 发现目录存在，ok，逐级创建子目录即可 进入目录 cd /root/.local/share/pyppeteer/local-chromium/588429/chrome-linux 解压缩上面下载的chrome-linux.zip 把chrome-linux文件夹下所有内容上传到/root/.local/share/pyppeteer/local-chromium/588429/chrome-linux 给运行权限 cd /root/.local/share/pyppeteer/local-chromium/588429/chrome-linux/ chmod +x chrome chmod +x chrome_sandbox 运行chrome /root/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome 报错： error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory 解决错误 yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y 解决方法 2 修改下载地址为淘宝地址 vim /usr/local/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py # 修改为taobao地址 DEFAULT_DOWNLOAD_HOST = 'https://npm.taobao.org/mirrors';#'https://storage.googleapis.com' linux环境运行报错问题问题 windows运行正常，linux环境报错：pyppeteer.errors.BrowserError: Browser closed unexpectedly [root@iZbp1i88wdqojke2dk2ugbZ ymsq.com]# python test1.py Traceback (most recent call last): File "test1.py", line 24, in <module> asyncio.get_event_loop().run_until_complete(getContent(link)) File "/usr/local/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete return future.result() File "test1.py", line 13, in getContent browser = await launch() File "/usr/local/lib/python3.8/site-packages/pyppeteer/launcher.py", line 305, in launch return await Launcher(options, **kwargs).launch() File "/usr/local/lib/python3.8/site-packages/pyppeteer/launcher.py", line 166, in launch self.browserWSEndpoint = get_ws_endpoint(self.url) File "/usr/local/lib/python3.8/site-packages/pyppeteer/launcher.py", line 225, in get_ws_endpoint raise BrowserError('Browser closed unexpectedly:\n') pyppeteer.errors.BrowserError: Browser closed unexpectedly: 解决方案： # 增加参数options={'args': ['--no-sandbox']} async def getContent(link): try: browser = await launch('args': ['--no-sandbox']) # 增加参数options={'args': ['--no-sandbox']} page = await browser.newPage() await page.goto(link) content = await page.content() doc = pq(content) print(content) #print('Quotes:', doc('.quote').length) await browser.close() # 关闭浏览器 return content except BadStatusLine as e: print("错误" + e.getContent) asyncio.get_event_loop().run_until_complete(getContent(link)) 问题 在实际运行中。我在基于tonado的api服务上对外提供这个功能。运行中发现大量chromium僵尸进程，导致系统卡死。也就是说browser.close()并没有真正关闭chromium进程。 有多少个僵尸进程呢 [root@sdsdsdZ ~]# ps aux|grep pyppeteer/local-chromium | wc -l 192 可怕。192个。先杀掉所有含有pyppeteer的进程吧 ps aux | grep pyppeteer | awk '{print $2}' | xargs kill -9 解决方案 关闭页面 await page.close() # 增加关闭页面，观察下 相关github https://github.com/pyppeteer/pyppeteer/issues/135
有个功能点之前不需要，删掉了，现在又需要还得把他找回来。确定git能完成这项任务，但是学会之后并没有实操，早已经不记得了。 这里记录一下操作过程 git命令查看文件删除hash戳 git log --all --full-history upload\xxx.php 输出(已做处理，不要照抄): commit d6cd1e2bd19e03a81132a23b2025920577f84e37 Author: zzz zzz@qq.com Date: Wed Apr 11 11:11:11 2020 +0800 修改记录。。。。。 ok，我们明确知道删除改文件的commit是d6cd1e2bd19e03a81132a23b2025920577f84e37 2. 查看该提交文件记录 git show d6cd1e2bd19e03a81132a23b2025920577f84e37 upload\xxx.php 3. 找回文件,git checkout 后面指定hash，紧接着加一个"~1"，表示从删除前的commit获取 git checkout d6cd1e2bd19e03a81132a23b2025920577f84e37~1 upload\xxx.php all done
当前环境查看 uname -r 3.10.0-514.el7.x86_64 安装新版本内核 rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install kernel-ml -y 查看当前已安装内核 查看已安装版本 rpm -qa | grep kernel kernel-3.10.0-1062.18.1.el7.x86_64 kernel-tools-libs-3.10.0-1062.18.1.el7.x86_64 kernel-tools-3.10.0-1062.18.1.el7.x86_64 kernel-ml-devel-5.5.13-1.el7.elrepo.x86_64 kernel-3.10.0-957.el7.x86_64 kernel-headers-3.10.0-1062.18.1.el7.x86_64 kernel-ml-5.5.13-1.el7.elrepo.x86_64 卸载安装的内核 rpm -e kernel-ml-devel-5.5.13-1.el7.elrepo.x86_64 rpm -e kernel-ml-5.5.13-1.el7.elrepo.x86_64 查看启动项目 awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 0 : CentOS Linux (5.5.13-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (3.10.0-1062.18.1.el7.x86_64) 7 (Core) 2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core) 3 : CentOS Linux (0-rescue-27c6b54f6ca241c6884f74f0193db5e9) 7 (Core) 选择0号，5.5内核启动 grub2-set-default 0 #重启 reboot 错误 选择5.5内核启动后，开机报错无法进入系统 /dev/centos/root does not exist 解决方法 1. 启动时候选择'linux rescue' 2. 使用命令 dracut -f 开启bbr sysctl -a|grep tcp_congestion_control net.ipv4.tcp_congestion_control = cubic // 当前拥塞控制算法是cubic
生成crt和private key openssl req -new -newkey rsa:2048 -nodes -keyout your_domain_name.key -out your_domain_name.csr 打开godaddy把生成的your_domain_name.csr提供给godaddy。godaddy会去生成证书。 下载godaddy证书。两个文件，一个大概叫做85814333f334c3c5d.crt,另一个大概叫做叫做gd_bundle-g2-g1.crt。把两个文件上传到服务器某一目录下。执行如下操作合并两个文件 cat 85814333f334c3c5d.crt gd_bundle-g2-g1.crt >> your_domain_name.cst 打开nginx网站配置文件，加入 listen 443 ssl http2; ssl on; ssl_certificate /存储路径/your_domain_name; ssl_certificate_key /存储路径/your_domain_name.cst; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_session_cache builtin:1000 shared:SSL:10m; 重启nginx搞定