studio中可能遇到的.9-patch图片报错处理

本文介绍如何在build.gradle中配置以禁用Android Studio对PNG文件的合法性检查,通过添加特定设置来避免因PNG问题导致的构建错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在build.gradle里添加以下两句:
aaptOptions.cruncherEnabled = false 
aaptOptions.useNewCruncher = false,


就直接添加到buildToolsVersion的下方即可。这个可以关闭Android Studio的PNG合法性检查。。。然后就可以大胆的用图了。。。
命令行运行pip install dlib==19.24.0 --no-cache-dir --verbose报错: Using pip 25.1.1 from D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip (python 3.13) Collecting dlib==19.24.0 Downloading dlib-19.24.0.tar.gz (3.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 100.9 kB/s eta 0:00:00 Running command python setup.py egg_info C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence &#39;\(&#39; major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence &#39;\(&#39; minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence &#39;\(&#39; patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: &#39;tests_require&#39; warnings.warn(msg) running egg_info creating C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info writing C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\PKG-INFO writing dependency_links to C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\dependency_links.txt writing top-level names to C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\top_level.txt writing manifest file &#39;C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt&#39; reading manifest file &#39;C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt&#39; reading manifest template &#39;MANIFEST.in&#39; no previously-included directories found matching &#39;tools\python\build*&#39; no previously-included directories found matching &#39;dlib\cmake_utils\*\build*&#39; no previously-included directories found matching &#39;dlib\test&#39; warning: no previously-included files matching &#39;*.pyc&#39; found anywhere in distribution writing manifest file &#39;C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt&#39; Preparing metadata (setup.py) ... done Building wheels for collected packages: dlib DEPRECATION: Building &#39;dlib&#39; using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of &#39;dlib&#39;. Discussion can be found at https://github.com/pypa/pip/issues/6334 Running command python setup.py bdist_wheel C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence &#39;\(&#39; major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence &#39;\(&#39; minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence &#39;\(&#39; patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: &#39;tests_require&#39; warnings.warn(msg) running bdist_wheel running build running build_py running build_ext C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cmake_version) < &#39;3.1.0&#39;: Building extension for Python 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)] Invoking CMake setup: &#39;cmake C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\build\lib.win-amd64-cpython-313 -DPYTHON_EXECUTABLE=D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\build\lib.win-amd64-cpython-313 -A x64&#39; Traceback (most recent call last): File "<string>", line 2, in <module> exec(compile(&#39;&#39;&#39; ~~~~^^^^^^^^^^^^ # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<32 lines>... exec(compile(setup_py_code, filename, "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ &#39;&#39;&#39; % (&#39;C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\setup.py&#39;,), "<pip-setuptools-caller>", "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<pip-setuptools-caller>", line 35, in <module> File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 222, in <module> setup( ~~~~~^ name=&#39;dlib&#39;, ^^^^^^^^^^^^ ...<38 lines>... ], ^^ ) ^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\__init__.py", line 115, in setup return distutils.core.setup(**attrs) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\core.py", line 186, in setup return run_commands(dist) File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\core.py", line 202, in run_commands dist.run_commands() ~~~~~~~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1002, in run_commands self.run_command(cmd) ~~~~~~~~~~~~~~~~^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\command\bdist_wheel.py", line 370, in run self.run_command("build") ~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\cmd.py", line 357, in run_command self.distribution.run_command(command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run self.run_command(cmd_name) ~~~~~~~~~~~~~~~~^^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\cmd.py", line 357, in run_command self.distribution.run_command(command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 134, in run self.build_extension(ext) ~~~~~~~~~~~~~~~~~~~~^^^^^ File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 419, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command &#39;[&#39;cmake&#39;, &#39;C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\tools\\python&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\build\\lib.win-amd64-cpython-313&#39;, &#39;-DPYTHON_EXECUTABLE=D:\\Users\\徐庆凯\\AppData\\Local\\Programs\\Python\\Python313\\python.exe&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\build\\lib.win-amd64-cpython-313&#39;, &#39;-A&#39;, &#39;x64&#39;]&#39; returned non-zero exit status 3221226505. error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: &#39;D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\python.exe&#39; -u -c &#39; exec(compile(&#39;"&#39;"&#39;&#39;"&#39;"&#39;&#39;"&#39;"&#39; # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py # # - It imports setuptools before invoking setup.py, to enable projects that directly # import from `distutils.core` to work with newer packaging standards. # - It provides a clear error message when setuptools is not installed. # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so # setuptools doesn&#39;"&#39;"&#39;t think the script is `-c`. This avoids the following warning: # manifest_maker: standard file &#39;"&#39;"&#39;-c&#39;"&#39;"&#39; not found". # - It generates a shim setup.py, for handling setup.cfg-only projects. import os, sys, tokenize, traceback try: import setuptools except ImportError: print( "ERROR: Can not execute `setup.py` since setuptools failed to import in " "the build environment with exception:", file=sys.stderr, ) traceback.print_exc() sys.exit(1) __file__ = %r sys.argv[0] = __file__ if os.path.exists(__file__): filename = __file__ with tokenize.open(__file__) as f: setup_py_code = f.read() else: filename = "<auto-generated setuptools caller>" setup_py_code = "from setuptools import setup; setup()" exec(compile(setup_py_code, filename, "exec")) &#39;"&#39;"&#39;&#39;"&#39;"&#39;&#39;"&#39;"&#39; % (&#39;"&#39;"&#39;C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\setup.py&#39;"&#39;"&#39;,), "<pip-setuptools-caller>", "exec"))&#39; bdist_wheel -d &#39;C:\Users\徐庆凯\AppData\Local\Temp\pip-wheel-m03b8zax&#39; cwd: C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\\ Building wheel for dlib (setup.py) ... error ERROR: Failed building wheel for dlib Running setup.py clean for dlib Running command python setup.py clean C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence &#39;\(&#39; major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence &#39;\(&#39; minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence &#39;\(&#39; patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: &#39;tests_require&#39; warnings.warn(msg) running clean removing &#39;build\temp.win-amd64-cpython-313&#39; (and everything under it) &#39;build\lib.win-amd64-cpython-313&#39; does not exist -- can&#39;t clean it &#39;build\bdist.win-amd64&#39; does not exist -- can&#39;t clean it &#39;build\scripts-3.13&#39; does not exist -- can&#39;t clean it removing &#39;build&#39; Failed to build dlib ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
06-21
<think>我们正在解决在Python3.13环境下使用pip安装dlib==19.24.0时出现的CMake配置错误和subprocess.CalledProcessError问题。根据引用[1]中的信息,我们可以尝试以下步骤:1.**确保系统有编译依赖**:dlib需要C++编译器和相关工具。在Linux上,安装build-essential和cmake。在macOS上,安装Xcode命令行工具。在Windows上,安装VisualStudio的C++构建工具。2.**设置环境变量(针对Linux/macOS)**:引用[1]提到,可以通过设置环境变量指定gcc和g++的路径。例如:```bashexportCC=/usr/bin/gccexportCXX=/usr/bin/g++```注意:路径可能因系统而异,请使用`whichgcc`和`whichg++`查看实际路径。3.**使用清华镜像源安装**:引用[1]建议使用清华镜像源安装face_recognition,这同样适用于dlib。我们可以先尝试安装dlib:```bashpipinstalldlib==19.24.0-ihttps://pypi.tuna.tsinghua.edu.cn/simple```4.**如果上述步骤失败,尝试从源码安装**:-下载dlib源码:https://github.com/davisking/dlib/releases-解压后进入目录,执行:```bashpythonsetup.pyinstall```5.**注意Python3.13的兼容性**:目前dlib可能尚未完全支持Python3.13。如果遇到兼容性问题,可以尝试:-使用较新的dlib版本(如果有)或较旧的Python版本(如3.10、3.11)。-在虚拟环境中安装,避免系统环境冲突。6.**错误日志分析**:如果仍然失败,请提供具体的错误日志,以便进一步分析。**步骤总结**:1.安装编译依赖。2.设置环境变量指定编译器(如果需要)。3.使用镜像源安装dlib。4.尝试源码安装。5.考虑Python版本兼容性。如果以上步骤不能解决,请提供具体的错误信息。</think>### 解决 Python 3.13 下安装 dlib==19.24.0 的 CMake 错误 安装 dlib 时出现 CMake 配置错误和 `subprocess.CalledProcessError` 通常是由于以下原因: 1. **编译器不兼容**:Python 3.13 可能需要更新的编译器 2. **CMake 版本过低**:dlib 需要 CMake ≥ 3.8.2 3. **依赖缺失**:缺少 C++ 构建工具链 4. **Python 版本兼容性**:dlib 19.24.0 可能未完全适配 Python 3.13 #### 解决方案步骤: 1. **升级构建工具**: ```bash # Linux sudo apt update && sudo apt install build-essential cmake # macOS (需安装 Xcode 命令行工具) xcode-select --install ``` 2. **设置环境变量**(关键步骤): ```bash # 指定正确的编译器路径(根据实际路径调整) export CC=/usr/bin/gcc export CXX=/usr/bin/g++ ``` 使用 `which gcc` 和 `which g++` 确认路径[^1] 3. **安装 CMake 最新版**: ```bash pip install --upgrade cmake ``` 4. **使用兼容性安装命令**: ```bash pip install dlib==19.24.0 \ --no-cache-dir \ --force-reinstall \ --config-settings="--global-option=--no" \ --config-settings="--global-option=--clean" \ -i https://pypi.tuna.tsinghua.edu.cn/simple ``` 5. **备选方案 - 从源码编译**: ```bash git clone https://github.com/davisking/dlib.git cd dlib mkdir build && cd build cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1 cmake --build . --config Release cd .. && pip install . ``` #### 验证安装: ```python import dlib print(dlib.__version__) # 应输出 19.24.0 ``` > **注意**:如果仍失败,建议: > 1. 临时降级到 Python 3.11/3.12 > 2. 使用虚拟环境隔离安装: > ```bash > python -m venv dlib_env > source dlib_env/bin/activate > ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值