python:BeautifulSoup 从 html中提取 image/jpeg;base64

该Python脚本利用BeautifulSoup库解析MDict词典文件中的HTML,提取以base64编码的JPEG或PNG图像,并将它们保存为本地文件。脚本接受命令行参数作为查询词,找到对应的词典条目,然后将提取的图片保存在img目录下,并在img_url.htm文件中创建一个链接列表以便查看。

BeautifulSoup 从 MDict 的 html中提取 image/jpeg;base64

extract_mdx_img.py

# -*- coding: UTF-8 -*-
import os
import sys
import bs4
import base64
from readmdict import MDX  # pip install readmdict

# data:image/jpeg;base64,/9j/
def base64ToImage(name, base64res):
    if base64res.startswith("data:image/jpeg"):
        ext = '.jpg'
    else:
        ext = '.png'	
    res = base64res.split(",")[1]
    img_b64decode = base64.b64decode(res)
    # 输出文件夹是否存在
    if not os.path.exists("img"):
        os.makedirs("img")
        print("mkdir img success")
    # 输出图片
    fname = "img/" +name +ext
    print(fname)
    with open(fname, 'wb') as img:
        img.write(img_b64decode)
    with open("img_url.htm","a+", encoding="utf8") as fp:
        url = f'<h3>{name}</h3> <img src="' +fname + '" /><p>\n'
        fp.write(url)

# main()
if len(sys.argv) ==2:
    queryWord = sys.argv[1]
else:
	print("usage: extract_mdx_img.py queryWord ")
	sys.exit(1)

path1 ="你的MDict 词典目录"
os.chdir(path1)
# 加载mdx文件
filename = "你的词典文件名"
mdx = MDX(filename)
headwords = [*mdx]       # 单词名列表
items = [*mdx.items()]   # 释义html源码列表
n = len(headwords)
m = len(items)
if n == m:
    print(f'加载成功:共{n}条')
else:
    print(f'ERROR:加载失败 {n}!={m}')
    sys.exit(2)

# 查词,返回单词和html文件
wordIndex = headwords.index(queryWord.encode())
word,html = items[wordIndex]
word,html = word.decode(), html.decode()
print(word)

# 从html中提取 image/jpeg;base64
soup = bs4.BeautifulSoup(html, features='html.parser')
i=0
for img in soup.find_all("img"):
    i +=1
    base64ToImage(f"{queryWord}_"+str(i), img.get("src"))
print("生成图片",i,"张")

运行 extract_mdict_img.py point

或者 python extract_mdict_img.py compass

显示图片,双击文件 img_url.htm

Looking in indexes: https://mirror.baidu.com/pypi/simple/, https://mirrors.aliyun.com/pypi/simple/ Requirement already satisfied: opencv-python in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (4.1.1.26) Collecting dlib Downloading https://mirrors.aliyun.com/pypi/packages/28/f4/f8949b18ec1df2ef05fc2ea1d1dd82ff2d050b8704b7d0d088017315c221/dlib-20.0.0.tar.gz (3.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 12.2 MB/s eta 0:00:0000:0100:01 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: matplotlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (2.2.3) Requirement already satisfied: pillow in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (8.2.0) Requirement already satisfied: requests in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (2.22.0) Requirement already satisfied: beautifulsoup4 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (4.11.1) Requirement already satisfied: scikit-learn in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (0.24.2) Requirement already satisfied: numpy>=1.14.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from opencv-python) (1.20.3) Requirement already satisfied: six>=1.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (1.16.0) Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (2.8.2) Requirement already satisfied: pytz in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (2019.3) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (3.0.9) Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (0.10.0) Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (1.1.0) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests) (3.0.4) Requirement already satisfied: idna<2.9,>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests) (2.8) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests) (1.25.6) Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests) (2019.9.11) Requirement already satisfied: soupsieve>1.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from beautifulsoup4) (2.3.2.post1) Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn) (2.1.0) Requirement already satisfied: scipy>=0.19.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn) (1.6.3) Requirement already satisfied: joblib>=0.11 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn) (0.14.1) Requirement already satisfied: setuptools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (56.2.0) Building wheels for collected packages: dlib Building wheel for dlib (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for dlib (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [252 lines of output] running bdist_wheel running build running build_ext Building extension for Python 3.7.4 (default, Aug 13 2019, 20:35:49) Invoking CMake setup: 'cmake /tmp/pip-install-9ool2zzu/dlib_7816ed707750450bb5cceeb2f0daf3b2/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-9ool2zzu/dlib_7816ed707750450bb5cceeb2f0daf3b2/build/lib.linux-x86_64-cpython-37 -DPYTHON_EXECUTABLE=/opt/conda/envs/python35-paddle120-env/bin/python -DDLIB_USE_FFMPEG=OFF -DCMAKE_BUILD_TYPE=Release' -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- 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 -- pybind11 v2.12.0 -- Found PythonInterp: /opt/conda/envs/python35-paddle120-env/bin/python (found suitable version "3.7.4", minimum required is "3.6") -- Found PythonLibs: /opt/conda/envs/python35-paddle120-env/lib/libpython3.7m.so -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- Using CMake version: 3.24.2 -- Compiling dlib version: 20.0.0 -- SSE4 instructions can be executed by the host processor. -- AVX instructions can be executed by the host processor. -- Enabling AVX instructions -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found X11: /usr/include -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found -- Looking for gethostbyname -- Looking for gethostbyname - found -- Looking for connect -- Looking for connect - found -- Looking for remove -- Looking for remove - found -- Looking for shmat -- Looking for shmat - found -- Looking for IceConnectionNumber in ICE -- Looking for IceConnectionNumber in ICE - found -- Found system copy of libpng: /usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libz.so -- Found system copy of libjpeg: /usr/lib/x86_64-linux-gnu/libjpeg.so -- Found WebP: /usr/lib/x86_64-linux-gnu/libwebp.so -- System copy of libwebp is either too old or broken. Will disable WebP support. -- Searching for JPEG XL -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for modules 'libjxl;libjxl_cms;libjxl_threads' -- No package 'libjxl' found -- No package 'libjxl_cms' found -- No package 'libjxl_threads' found ***************************************************************************** *** No JPEG XL libraries found. *** *** On Ubuntu 23.04 and newer you can install them by executing *** *** sudo apt install libjxl-dev *** *** *** *** Otherwise, you can find precompiled packages here: *** *** https://github.com/libjxl/libjxl/releases *** ***************************************************************************** -- Searching for BLAS and LAPACK -- Searching for BLAS and LAPACK -- Checking for module 'cblas' -- No package 'cblas' found -- Checking for module 'lapack' -- Found lapack, version 3.10.2 -- Looking for cblas_ddot -- Looking for cblas_ddot - not found -- 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 -- Found LAPACK library -- Found ATLAS BLAS library -- Looking for cblas_ddot -- Looking for cblas_ddot - found -- Looking for sgesv -- Looking for sgesv - not found -- Looking for sgesv_ -- Looking for sgesv_ - found -- Found CUDA: /usr/local/cuda (found suitable version "10.1", minimum required is "7.5") -- Looking for cuDNN install... -- Found cuDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so -- Building a CUDA test project to see if your compiler is compatible with CUDA... -- Building a cuDNN test project to check if you have the right version of cuDNN installed... -- Enabling CUDA support for dlib. DLIB WILL USE CUDA, compute capabilities: 50 -- Configuring done -- Generating done -- Build files have been written to: /tmp/pip-install-9ool2zzu/dlib_7816ed707750450bb5cceeb2f0daf3b2/build/temp.linux-x86_64-cpython-37 Invoking CMake build: 'cmake --build . --config Release -- -j64' [ 1%] Building NVCC (Device) object dlib_build/CMakeFiles/dlib.dir/cuda/dlib_generated_cusolver_dlibapi.cu.o [ 2%] Building NVCC (Device) object dlib_build/CMakeFiles/dlib.dir/cuda/dlib_generated_cuda_dlib.cu.o [ 3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o [ 4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o [ 5%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o [ 6%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o [ 7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o [ 8%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o [ 9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o [ 10%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o [ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o [ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o [ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/unicode/unicode.cpp.o [ 14%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o [ 15%] Building CXX object dlib_build/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o [ 16%] Building CXX object dlib_build/CMakeFiles/dlib.dir/fft/fft.cpp.o [ 17%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o [ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o [ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o [ 21%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o [ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o [ 23%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o [ 24%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o [ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o [ 26%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o [ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o [ 28%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o [ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o [ 30%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o [ 31%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o [ 32%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o [ 33%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_kernel.cpp.o [ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_http.cpp.o [ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o [ 36%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_iostream.cpp.o [ 37%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o [ 38%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o [ 40%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o [ 41%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o [ 42%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o [ 43%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o [ 44%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cpu_dlib.cpp.o [ 46%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o [ 45%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/async.cpp.o [ 47%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/mnist.cpp.o [ 48%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o [ 49%] Building CXX object dlib_build/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o [ 50%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/tensor_tools.cpp.o [ 51%] Building CXX object dlib_build/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o [ 52%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/cifar.cpp.o [ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/svm/auto.cpp.o [ 54%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o [ 55%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/canvas_drawing.cpp.o [ 56%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/drawable.cpp.o [ 57%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/style.cpp.o [ 58%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_1.cpp.o [ 60%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_2.cpp.o [ 61%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o [ 62%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/base_widgets.cpp.o [ 63%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o [ 64%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o [ 66%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/gpu_data.cpp.o [ 66%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cudnn_dlibapi.cpp.o [ 67%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o [ 68%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cublas_dlibapi.cpp.o [ 69%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cuda_data_ptr.cpp.o [ 70%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/curand_dlibapi.cpp.o [ 71%] Linking CXX static library libdlib.a [ 71%] Built target dlib [ 72%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/dlib.cpp.o [ 73%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/matrix.cpp.o [ 74%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/vector.cpp.o [ 75%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_c_trainer.cpp.o [ 76%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_rank_trainer.cpp.o [ 77%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/decision_functions.cpp.o [ 78%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/other.cpp.o [ 80%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/basic.cpp.o [ 81%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/cca.cpp.o [ 82%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/sequence_segmenter.cpp.o [ 83%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_struct.cpp.o [ 85%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image3.cpp.o [ 85%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image.cpp.o [ 86%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image2.cpp.o [ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/correlation_tracker.cpp.o [ 88%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/face_recognition.cpp.o [ 89%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image4.cpp.o [ 90%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/shape_predictor.cpp.o [ 91%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/rectangles.cpp.o [ 92%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/object_detection.cpp.o [ 93%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/numpy_returns.cpp.o [ 94%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/line.cpp.o [ 95%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/cnn_face_detector.cpp.o [ 96%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/gui.cpp.o [ 97%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/global_optimization.cpp.o [ 98%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image_dataset_metadata.cpp.o c++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions. CMakeFiles/_dlib_pybind11.dir/build.make:243: recipe for target 'CMakeFiles/_dlib_pybind11.dir/src/image2.cpp.o' failed make[2]: *** [CMakeFiles/_dlib_pybind11.dir/src/image2.cpp.o] Error 4 make[2]: *** Waiting for unfinished jobs.... CMakeFiles/Makefile2:117: recipe for target 'CMakeFiles/_dlib_pybind11.dir/all' failed make[1]: *** [CMakeFiles/_dlib_pybind11.dir/all] Error 2 Makefile:90: recipe for target 'all' failed make: *** [all] Error 2 Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module> main() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 262, in build_wheel metadata_directory) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 417, in build_wheel wheel_directory, config_settings) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir self.run_setup() File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in run_setup exec(code, locals()) File "<string>", line 273, in <module> File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 107, in setup return distutils.core.setup(**attrs) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 368, in run self.run_command("build") File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/command/build.py", line 131, in run self.run_command(cmd_name) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/tmp/pip-build-env-wy1gbu0h/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "<string>", line 168, in run File "<string>", line 209, in build_extension File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/subprocess.py", line 347, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j64']' returned non-zero exit status 2. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Failed to build dlib ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects [notice] A new release of pip available: 22.1.2 -> 24.0 [notice] To update, run: pip install --upgrade pip --2025-12-29 19:03:04-- https://github.com/davisking/dlib-models/raw/master/shape_predictor_68_face_landmarks.dat.bz2 Resolving github.com (github.com)... 20.205.243.166 Connecting to github.com (github.com)|20.205.243.166|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://raw.githubusercontent.com/davisking/dlib-models/master/shape_predictor_68_face_landmarks.dat.bz2 [following] --2025-12-29 19:03:05-- https://raw.githubusercontent.com/davisking/dlib-models/master/shape_predictor_68_face_landmarks.dat.bz2 Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
最新发布
12-30
conda update -n base -c conda-forge conda --yes Solving environment: failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/linux-64/repodata.json.bz2> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team. ConnectionError(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/free/linux-64/repodata.json.bz2 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x2b165a4e3128>: Failed to establish a new connection: [Errno -2] Name or service not known'))")) [scb3201@ln137%bscc-a6 ~]$ # 测试安装常用包 [scb3201@ln137%bscc-a6 ~]$ conda install -c conda-forge numpy pandas Solving environment: failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/r/noarch/repodata.json.bz2> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team. ConnectionError(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/r/noarch/repodata.json.bz2 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x2ba3d9347be0>: Failed to establish a new connection: [Errno -2] Name or service not known'))")) [scb3201@ln137%bscc-a6 ~]$ [scb3201@ln137%bscc-a6 ~]$ # 检查环境状态 [scb3201@ln137%bscc-a6 ~]$ conda list --revisions 2018-11-08 03:08:33 (rev 0) +_ipyw_jlab_nb_ext_conf-0.1.0 +alabaster-0.7.11 +anaconda-5.3.1 +anaconda-client-1.7.2 +anaconda-navigator-1.9.2 +anaconda-project-0.8.2 +appdirs-1.4.3 +asn1crypto-0.24.0 +astroid-2.0.4 +astropy-3.0.4 +atomicwrites-1.2.1 +attrs-18.2.0 +automat-0.7.0 +babel-2.6.0 +backcall-0.1.0 +backports-1.0 +backports.shutil_get_terminal_size-1.0.0 +beautifulsoup4-4.6.3 +bitarray-0.8.3 +bkcharts-0.2 +blas-1.0 +blaze-0.11.3 +bleach-2.1.4 +blosc-1.14.4 +bokeh-0.13.0 +boto-2.49.0 +bottleneck-1.2.1 +bzip2-1.0.6 +ca-certificates-2018.03.07 +cairo-1.14.12 +certifi-2018.8.24 +cffi-1.11.5 +chardet-3.0.4 +click-6.7 +cloudpickle-0.5.5 +clyent-1.2.2 +colorama-0.3.9 +conda-4.5.11 +conda-build-3.15.1 +conda-env-2.6.0 +constantly-15.1.0 +contextlib2-0.5.5 +cryptography-2.3.1 +curl-7.61.0 +cycler-0.10.0 +cython-0.28.5 +cytoolz-0.9.0.1 +dask-0.19.1 +dask-core-0.19.1 +datashape-0.5.4 +dbus-1.13.2 +decorator-4.3.0 +defusedxml-0.5.0 +distributed-1.23.1 +docutils-0.14 +entrypoints-0.2.3 +et_xmlfile-1.0.1 +expat-2.2.6 +fastcache-1.0.2 +filelock-3.0.8 +flask-1.0.2 +flask-cors-3.0.6 +fontconfig-2.13.0 +freetype-2.9.1 +fribidi-1.0.5 +get_terminal_size-1.0.0 +gevent-1.3.6 +glib-2.56.2 +glob2-0.6 +gmp-6.1.2 +gmpy2-2.0.8 +graphite2-1.3.12 +greenlet-0.4.15 +gst-plugins-base-1.14.0 +gstreamer-1.14.0 +h5py-2.8.0 +harfbuzz-1.8.8 +hdf5-1.10.2 +heapdict-1.0.0 +html5lib-1.0.1 +hyperlink-18.0.0 +icu-58.2 +idna-2.7 +imageio-2.4.1 +imagesize-1.1.0 +incremental-17.5.0 +intel-openmp-2019.0 +ipykernel-4.9.0 +ipython-6.5.0 +ipython_genutils-0.2.0 +ipywidgets-7.4.1 +isort-4.3.4 +itsdangerous-0.24 +jbig-2.1 +jdcal-1.4 +jedi-0.12.1 +jeepney-0.3.1 +jinja2-2.10 +jpeg-9b +jsonschema-2.6.0 +jupyter-1.0.0 +jupyter_client-5.2.3 +jupyter_console-5.2.0 +jupyter_core-4.4.0 +jupyterlab-0.34.9 +jupyterlab_launcher-0.13.1 +keyring-13.2.1 +kiwisolver-1.0.1 +lazy-object-proxy-1.3.1 +libcurl-7.61.0 +libedit-3.1.20170329 +libffi-3.2.1 +libgcc-ng-8.2.0 +libgfortran-ng-7.3.0 +libpng-1.6.34 +libsodium-1.0.16 +libssh2-1.8.0 +libstdcxx-ng-8.2.0 +libtiff-4.0.9 +libtool-2.4.6 +libuuid-1.0.3 +libxcb-1.13 +libxml2-2.9.8 +libxslt-1.1.32 +llvmlite-0.24.0 +locket-0.2.0 +lxml-4.2.5 +lzo-2.10 +markupsafe-1.0 +matplotlib-2.2.3 +mccabe-0.6.1 +mistune-0.8.3 +mkl-2019.0 +mkl-service-1.1.2 +mkl_fft-1.0.4 +mkl_random-1.0.1 +more-itertools-4.3.0 +mpc-1.1.0 +mpfr-4.0.1 +mpmath-1.0.0 +msgpack-python-0.5.6 +multipledispatch-0.6.0 +navigator-updater-0.2.1 +nbconvert-5.4.0 +nbformat-4.4.0 +ncurses-6.1 +networkx-2.1 +nltk-3.3.0 +nose-1.3.7 +notebook-5.6.0 +numba-0.39.0 +numexpr-2.6.8 +numpy-1.15.1 +numpy-base-1.15.1 +numpydoc-0.8.0 +odo-0.5.1 +olefile-0.46 +openpyxl-2.5.6 +openssl-1.0.2p +packaging-17.1 +pandas-0.23.4 +pandoc-1.19.2.1 +pandocfilters-1.4.2 +pango-1.42.4 +parso-0.3.1 +partd-0.3.8 +patchelf-0.9 +path.py-11.1.0 +pathlib2-2.3.2 +patsy-0.5.0 +pcre-8.42 +pep8-1.7.1 +pexpect-4.6.0 +pickleshare-0.7.4 +pillow-5.2.0 +pip-10.0.1 +pixman-0.34.0 +pkginfo-1.4.2 +pluggy-0.7.1 +ply-3.11 +prometheus_client-0.3.1 +prompt_toolkit-1.0.15 +psutil-5.4.7 +ptyprocess-0.6.0 +py-1.6.0 +pyasn1-0.4.4 +pyasn1-modules-0.2.2 +pycodestyle-2.4.0 +pycosat-0.6.3 +pycparser-2.18 +pycrypto-2.6.1 +pycurl-7.43.0.2 +pyflakes-2.0.0 +pygments-2.2.0 +pylint-2.1.1 +pyodbc-4.0.24 +pyopenssl-18.0.0 +pyparsing-2.2.0 +pyqt-5.9.2 +pysocks-1.6.8 +pytables-3.4.4 +pytest-3.8.0 +pytest-arraydiff-0.2 +pytest-astropy-0.4.0 +pytest-doctestplus-0.1.3 +pytest-openfiles-0.3.0 +pytest-remotedata-0.3.0 +python-3.7.0 +python-dateutil-2.7.3 +pytz-2018.5 +pywavelets-1.0.0 +pyyaml-3.13 +pyzmq-17.1.2 +qt-5.9.6 +qtawesome-0.4.4 +qtconsole-4.4.1 +qtpy-1.5.0 +readline-7.0 +requests-2.19.1 +rope-0.11.0 +ruamel_yaml-0.15.46 +scikit-image-0.14.0 +scikit-learn-0.19.2 +scipy-1.1.0 +seaborn-0.9.0 +secretstorage-3.1.0 +send2trash-1.5.0 +service_identity-17.0.0 +setuptools-40.2.0 +simplegeneric-0.8.1 +singledispatch-3.4.0.3 +sip-4.19.8 +six-1.11.0 +snappy-1.1.7 +snowballstemmer-1.2.1 +sortedcollections-1.0.1 +sortedcontainers-2.0.5 +sphinx-1.7.9 +sphinxcontrib-1.0 +sphinxcontrib-websupport-1.1.0 +spyder-3.3.1 +spyder-kernels-0.2.6 +sqlalchemy-1.2.11 +sqlite-3.24.0 +statsmodels-0.9.0 +sympy-1.2 +tblib-1.3.2 +terminado-0.8.1 +testpath-0.3.1 +tk-8.6.8 +toolz-0.9.0 +tornado-5.1 +tqdm-4.26.0 +traitlets-4.3.2 +twisted-18.7.0 +unicodecsv-0.14.1 +unixodbc-2.3.7 +urllib3-1.23 +wcwidth-0.1.7 +webencodings-0.5.1 +werkzeug-0.14.1 +wheel-0.31.1 +widgetsnbextension-3.4.1 +wrapt-1.10.11 +xlrd-1.1.0 +xlsxwriter-1.1.0 +xlwt-1.3.0 +xz-5.2.4 +yaml-0.1.7 +zeromq-4.2.5 +zict-0.1.3 +zlib-1.2.11 +zope-1.0 +zope.interface-4.5.0 [scb3201@ln137%bscc-a6 ~]$ conda info active environment : base active env location : /public1/home/scb3201/anaconda3 shell level : 1 user config file : /public1/home/scb3201/.condarc populated config files : /public1/home/scb3201/.condarc conda version : 4.5.11 conda-build version : 3.15.1 python version : 3.7.0.final.0 base environment : /public1/home/scb3201/anaconda3 (writable) channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/linux-64 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/linux-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/linux-64 https://repo.anaconda.com/pkgs/pro/noarch package cache : /public1/home/scb3201/anaconda3/pkgs /public1/home/scb3201/.conda/pkgs envs directories : /public1/home/scb3201/anaconda3/envs /public1/home/scb3201/.conda/envs platform : linux-64 user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Linux/3.10.0-1160.118.1.el7.x86_64 centos/7 glibc/2.17 UID:GID : 4238:4238 netrc file : None offline mode : False [scb3201@ln137%bscc-a6 ~]$ curl -v https://repo.anaconda.com/pkgs/r/linux-64/repodata.json.bz2 * Could not resolve host: repo.anaconda.com * Closing connection 0 curl: (6) Could not resolve host: repo.anaconda.com [scb3201@ln137%bscc-a6 ~]$ curl -I https://repo.anaconda.com/pkgs/r/linux-64/repodata.json.bz2 curl: (6) Could not resolve host: repo.anaconda.com [scb3201@ln137%bscc-a6 ~]$ echo $http_proxy # 检查代理变量 [scb3201@ln137%bscc-a6 ~]$ ping 8.8.8.8 # 测试基础网络连通性 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
11-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值