我正在尝试使用 pip 安装 ctcdecode 但出现此错误:
Collecting ctcdecode
Using cached ctcdecode-1.0.2.tar.gz (125 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [19 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\User\AppData\Local\Temp\pip-install-t7lei6su\ctcdecode_0562497126b04a9186f962c9f35d1f7b\setup.py", line 29, in <module>
download_extract('https://github.com/parlance/ctcdecode/releases/download/v1.0/boost_1_67_0.tar.gz',
File "C:\Users\User\AppData\Local\Temp\pip-install-t7lei6su\ctcdecode_0562497126b04a9186f962c9f35d1f7b\setup.py", line 22, in download_extract
tar.extractall('third_party/')
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 2268, in extractall
self._extract_one(tarinfo, path, set_attrs=not tarinfo.isdir(),
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 2335, in _extract_one
self._handle_fatal_error(e)
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 2331, in _extract_one
self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 2414, in _extract_member
self.makefile(tarinfo, targetpath)
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 2459, in makefile
with bltn_open(targetpath, "wb") as target:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'third_party\\boost_1_67_0\\libs\\geometry\\doc\\html\\geometry\\spatial_indexes\\rtree_examples\\specializing_index__indexable_function_object___storing_shared_pointers_in_the_rtree.html'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
我需要使用它,因为这是一个项目的依赖项,所以请不要建议该模块的替代方案。
我尝试直接从其 Github 页面设置这个东西,但我也遇到了错误。
我使用的是python 3.12
编辑: 经过一番故障排除后,我现在遇到了另一个错误:(错误太大我只能分享一半)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\Yash\Downloads\Compressed\ctcdecode-master\ctcdecode-master\setup.py", line 131, in <module>
setup(
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\__init__.py", line 117, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\core.py", line 183, in setup
return run_commands(dist)
^^^^^^^^^^^^^^^^^^
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\core.py", line 199, in run_commands
dist.run_commands()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 954, in run_commands
self.run_command(cmd)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py", line 999, in run_command
super().run_command(command)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
cmd_obj.run()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\command\bdist_wheel.py", line 410, in run
self.run_command("build")
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py", line 999, in run_command
super().run_command(command)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
cmd_obj.run()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py", line 999, in run_command
super().run_command(command)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
cmd_obj.run()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\command\build_ext.py", line 98, in run
_build_ext.run(self)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 359, in run
self.build_extensions()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\utils\cpp_extension.py", line 871, in build_extensions
build_ext.build_extensions(self)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 476, in build_extensions
self._build_extensions_serial()
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 502, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\command\build_ext.py", line 263, in build_extension
_build_ext.build_extension(self, ext)
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 557, in build_extension
objects = self.compiler.compile(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\utils\cpp_extension.py", line 843, in win_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\utils\cpp_extension.py", line 1774, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "C:\Users\Yash\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\utils\cpp_extension.py", line 2112, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension
[end of output]
编辑2: 我使用 pip 版本 19.2.3 安装了 python 3.8 并收到此错误:
Processing c:\users\user\downloads\compressed\ctcdecode-master\ctcdecode-master
ERROR: Command errored out with exit status 1:
command: 'c:\users\user\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-build-707o2ed5\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-build-707o2ed5\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: C:\Users\user\AppData\Local\Temp\pip-req-build-707o2ed5\
Complete output (15 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\user\AppData\Local\Temp\pip-req-build-707o2ed5\setup.py", line 30, in <module>
download_extract(
File "C:\Users\user\AppData\Local\Temp\pip-req-build-707o2ed5\setup.py", line 21, in download_extract
tar.extractall("third_party/")
File "c:\users\user\appdata\local\programs\python\python38\lib\tarfile.py", line 2026, in extractall
self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),
File "c:\users\user\appdata\local\programs\python\python38\lib\tarfile.py", line 2067, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
File "c:\users\user\appdata\local\programs\python\python38\lib\tarfile.py", line 2139, in _extract_member
self.makefile(tarinfo, targetpath)
File "c:\users\user\appdata\local\programs\python\python38\lib\tarfile.py", line 2180, in makefile
with bltn_open(targetpath, "wb") as target:
FileNotFoundError: [Errno 2] No such file or directory: 'third_party\\boost_1_67_0\\libs\\geometry\\doc\\html\\geometry\\reference\\spatial_indexes\\boost__geometry__index__rtree\\rtree_parameters_type_const____indexable_getter_const____value_equal_const____allocator_type_const___.html'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
此后,我将 pip 升级到版本 24.3.1,并收到与 torch 相关的不同错误
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\user\AppData\Local\Temp\pip-build-env-3hwtzx4l\overlay\Lib\site-packages\setuptools\build_meta.py", line 333, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "C:\Users\user\AppData\Local\Temp\pip-build-env-3hwtzx4l\overlay\Lib\site-packages\setuptools\build_meta.py", line 303, in _get_build_requires
self.run_setup()
File "C:\Users\user\AppData\Local\Temp\pip-build-env-3hwtzx4l\overlay\Lib\site-packages\setuptools\build_meta.py", line 521, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\user\AppData\Local\Temp\pip-build-env-3hwtzx4l\overlay\Lib\site-packages\setuptools\build_meta.py", line 319, in run_setup
exec(code, locals())
File "<string>", line 10, in <module>
ModuleNotFoundError: No module named 'torch'
[end of output]
对于原始错误,从包含的 Boost gzipped tar 文件中提取 HTML 文件,您可能会遇到 Windows 文件路径限制。看起来是 260。
boost_1_67_0.tar.gz
文件中包含的某些文件非常长(显然是由于命名空间原因),例如 boost_1_67_0/libs/geometry/doc/html/geometry/reference/spatial_indexes/boost__geometry__index__rtree/rtree_parameters_type_const____indexable_getter_const____value_equal_const____allocator_type_const___.html
,有 207 个字符。这既不是您在错误中看到的文件路径,也不是 260 个字符,可能是因为
您在错误中看到的文件路径是 tar 文件中提取的第一个超出字符限制的文件路径。 (如果这个成功,另一个更长的会显示相同的错误。)
实际提取的文件路径更长:已经预先添加了
third_party
目录,此外,如果您在 home/users 目录中的虚拟环境中工作,则可能预先添加了几个子目录,很容易就会超过260 个字符。 (我将留给读者作为练习来计算
错误中文件路径的实际路径长度。)
我没有直接的解决方案,因为我不使用 Windows。另外,这可能取决于您使用的 Windows 版本。
但是搜索 Windows 上的路径长度限制以及如何更改它可能会为您提供解决方案。例如,我在超级用户上遇到了这个相关问题,在那里我了解了 Windows 中的最大文件路径长度。
更官方的 Windows / Microsoft 文档有例如https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
我不知道您是否可以应用这些更改以允许更长的路径长度而不弄乱您当前的系统。
也许另一种选择是使用 WSL;我不知道这是否有效。 这里有一个关于此问题的 Reddit 帖子,并且可能还有其他相关信息来源。或者也许尝试起来既快速又简单,并且可能比更改 Windows 默认路径长度更安全。
最后一点:我并不是说这是问题所在,但考虑到这个奇怪的错误,我发现这很可能是问题。